From 9f0518c3815351bbb1c3498717808c5ed89248aa Mon Sep 17 00:00:00 2001 From: Siddharth Suresh Date: Fri, 15 Sep 2023 14:51:58 -0700 Subject: [PATCH] Update to use new xdr and fix invocation --- Makefile | 4 +- docs/en/api.rst | 1743 ----------------- stellar_sdk/transaction_builder.py | 12 +- stellar_sdk/xdr/__init__.py | 774 ++++---- stellar_sdk/xdr/account_entry.py | 79 +- stellar_sdk/xdr/account_entry_ext.py | 31 +- stellar_sdk/xdr/account_entry_extension_v1.py | 32 +- .../xdr/account_entry_extension_v1_ext.py | 31 +- stellar_sdk/xdr/account_entry_extension_v2.py | 52 +- .../xdr/account_entry_extension_v2_ext.py | 31 +- stellar_sdk/xdr/account_entry_extension_v3.py | 39 +- stellar_sdk/xdr/account_flags.py | 11 +- stellar_sdk/xdr/account_id.py | 16 +- stellar_sdk/xdr/account_merge_result.py | 35 +- stellar_sdk/xdr/account_merge_result_code.py | 11 +- stellar_sdk/xdr/allow_trust_op.py | 37 +- stellar_sdk/xdr/allow_trust_result.py | 21 +- stellar_sdk/xdr/allow_trust_result_code.py | 11 +- stellar_sdk/xdr/alpha_num12.py | 32 +- stellar_sdk/xdr/alpha_num4.py | 32 +- stellar_sdk/xdr/asset.py | 43 +- stellar_sdk/xdr/asset_code.py | 43 +- stellar_sdk/xdr/asset_code12.py | 17 +- stellar_sdk/xdr/asset_code4.py | 17 +- stellar_sdk/xdr/asset_type.py | 11 +- stellar_sdk/xdr/auth.py | 22 +- stellar_sdk/xdr/auth_cert.py | 39 +- stellar_sdk/xdr/authenticated_message.py | 32 +- stellar_sdk/xdr/authenticated_message_v0.py | 41 +- .../begin_sponsoring_future_reserves_op.py | 21 +- ...begin_sponsoring_future_reserves_result.py | 65 +- ..._sponsoring_future_reserves_result_code.py | 11 +- stellar_sdk/xdr/bucket_entry.py | 49 +- stellar_sdk/xdr/bucket_entry_type.py | 11 +- stellar_sdk/xdr/bucket_metadata.py | 32 +- stellar_sdk/xdr/bucket_metadata_ext.py | 22 +- .../xdr/bump_footprint_expiration_op.py | 32 +- .../xdr/bump_footprint_expiration_result.py | 56 +- .../bump_footprint_expiration_result_code.py | 11 +- stellar_sdk/xdr/bump_sequence_op.py | 21 +- stellar_sdk/xdr/bump_sequence_result.py | 21 +- stellar_sdk/xdr/bump_sequence_result_code.py | 11 +- stellar_sdk/xdr/change_trust_asset.py | 49 +- stellar_sdk/xdr/change_trust_op.py | 30 +- stellar_sdk/xdr/change_trust_result.py | 26 +- stellar_sdk/xdr/change_trust_result_code.py | 11 +- stellar_sdk/xdr/claim_atom.py | 49 +- stellar_sdk/xdr/claim_atom_type.py | 11 +- stellar_sdk/xdr/claim_claimable_balance_op.py | 21 +- .../xdr/claim_claimable_balance_result.py | 56 +- .../claim_claimable_balance_result_code.py | 11 +- stellar_sdk/xdr/claim_liquidity_atom.py | 49 +- stellar_sdk/xdr/claim_offer_atom.py | 52 +- stellar_sdk/xdr/claim_offer_atom_v0.py | 54 +- stellar_sdk/xdr/claim_predicate.py | 73 +- stellar_sdk/xdr/claim_predicate_type.py | 11 +- stellar_sdk/xdr/claimable_balance_entry.py | 54 +- .../xdr/claimable_balance_entry_ext.py | 31 +- .../claimable_balance_entry_extension_v1.py | 34 +- ...laimable_balance_entry_extension_v1_ext.py | 22 +- stellar_sdk/xdr/claimable_balance_flags.py | 11 +- stellar_sdk/xdr/claimable_balance_id.py | 30 +- stellar_sdk/xdr/claimable_balance_id_type.py | 11 +- stellar_sdk/xdr/claimant.py | 30 +- stellar_sdk/xdr/claimant_type.py | 11 +- stellar_sdk/xdr/claimant_v0.py | 32 +- .../xdr/clawback_claimable_balance_op.py | 21 +- .../xdr/clawback_claimable_balance_result.py | 61 +- .../clawback_claimable_balance_result_code.py | 11 +- stellar_sdk/xdr/clawback_op.py | 39 +- stellar_sdk/xdr/clawback_result.py | 21 +- stellar_sdk/xdr/clawback_result_code.py | 11 +- .../config_setting_contract_bandwidth_v0.py | 40 +- .../xdr/config_setting_contract_compute_v0.py | 44 +- .../xdr/config_setting_contract_events_v0.py | 74 + ...fig_setting_contract_execution_lanes_v0.py | 21 +- ...fig_setting_contract_historical_data_v0.py | 21 +- .../config_setting_contract_ledger_cost_v0.py | 105 +- stellar_sdk/xdr/config_setting_entry.py | 297 +-- stellar_sdk/xdr/config_setting_id.py | 11 +- stellar_sdk/xdr/config_upgrade_set.py | 26 +- stellar_sdk/xdr/config_upgrade_set_key.py | 34 +- stellar_sdk/xdr/contract_code_entry.py | 38 +- stellar_sdk/xdr/contract_cost_param_entry.py | 38 +- stellar_sdk/xdr/contract_cost_params.py | 26 +- stellar_sdk/xdr/contract_cost_type.py | 13 +- stellar_sdk/xdr/contract_data_durability.py | 11 +- stellar_sdk/xdr/contract_data_entry.py | 48 +- stellar_sdk/xdr/contract_event.py | 46 +- stellar_sdk/xdr/contract_event_body.py | 31 +- stellar_sdk/xdr/contract_event_type.py | 11 +- stellar_sdk/xdr/contract_event_v0.py | 36 +- stellar_sdk/xdr/contract_executable.py | 32 +- stellar_sdk/xdr/contract_executable_type.py | 11 +- stellar_sdk/xdr/contract_id_preimage.py | 45 +- .../xdr/contract_id_preimage_from_address.py | 30 +- stellar_sdk/xdr/contract_id_preimage_type.py | 11 +- stellar_sdk/xdr/create_account_op.py | 33 +- stellar_sdk/xdr/create_account_result.py | 21 +- stellar_sdk/xdr/create_account_result_code.py | 11 +- .../xdr/create_claimable_balance_op.py | 44 +- .../xdr/create_claimable_balance_result.py | 79 +- .../create_claimable_balance_result_code.py | 11 +- stellar_sdk/xdr/create_contract_args.py | 35 +- .../xdr/create_passive_sell_offer_op.py | 42 +- stellar_sdk/xdr/crypto_key_type.py | 11 +- stellar_sdk/xdr/curve25519_public.py | 22 +- stellar_sdk/xdr/curve25519_secret.py | 22 +- stellar_sdk/xdr/data_entry.py | 45 +- stellar_sdk/xdr/data_entry_ext.py | 22 +- stellar_sdk/xdr/data_value.py | 17 +- stellar_sdk/xdr/decorated_signature.py | 32 +- stellar_sdk/xdr/diagnostic_event.py | 34 +- stellar_sdk/xdr/dont_have.py | 30 +- stellar_sdk/xdr/duration.py | 16 +- stellar_sdk/xdr/encrypted_body.py | 17 +- .../end_sponsoring_future_reserves_result.py | 45 +- ..._sponsoring_future_reserves_result_code.py | 11 +- stellar_sdk/xdr/envelope_type.py | 11 +- stellar_sdk/xdr/error.py | 31 +- stellar_sdk/xdr/error_code.py | 11 +- stellar_sdk/xdr/eviction_iterator.py | 78 + stellar_sdk/xdr/expiration_entry.py | 72 + stellar_sdk/xdr/extension_point.py | 22 +- stellar_sdk/xdr/fee_bump_transaction.py | 47 +- .../xdr/fee_bump_transaction_envelope.py | 37 +- stellar_sdk/xdr/fee_bump_transaction_ext.py | 22 +- .../xdr/fee_bump_transaction_inner_tx.py | 30 +- stellar_sdk/xdr/flood_advert.py | 21 +- stellar_sdk/xdr/flood_demand.py | 21 +- .../xdr/generalized_transaction_set.py | 33 +- stellar_sdk/xdr/hash.py | 17 +- stellar_sdk/xdr/hash_id_preimage.py | 57 +- .../xdr/hash_id_preimage_contract_id.py | 35 +- .../xdr/hash_id_preimage_operation_id.py | 37 +- stellar_sdk/xdr/hash_id_preimage_revoke_id.py | 51 +- .../hash_id_preimage_soroban_authorization.py | 43 +- stellar_sdk/xdr/hello.py | 68 +- stellar_sdk/xdr/hmac_sha256_key.py | 22 +- stellar_sdk/xdr/hmac_sha256_mac.py | 22 +- stellar_sdk/xdr/host_function.py | 48 +- stellar_sdk/xdr/host_function_type.py | 11 +- stellar_sdk/xdr/inflation_payout.py | 30 +- stellar_sdk/xdr/inflation_result.py | 37 +- stellar_sdk/xdr/inflation_result_code.py | 11 +- stellar_sdk/xdr/inner_transaction_result.py | 41 +- .../xdr/inner_transaction_result_ext.py | 22 +- .../xdr/inner_transaction_result_pair.py | 33 +- .../xdr/inner_transaction_result_result.py | 37 +- stellar_sdk/xdr/int128_parts.py | 30 +- stellar_sdk/xdr/int256_parts.py | 43 +- stellar_sdk/xdr/int32.py | 17 +- stellar_sdk/xdr/int64.py | 17 +- stellar_sdk/xdr/invoke_contract_args.py | 87 + stellar_sdk/xdr/invoke_host_function_op.py | 35 +- .../xdr/invoke_host_function_result.py | 52 +- .../xdr/invoke_host_function_result_code.py | 11 +- .../invoke_host_function_success_pre_image.py | 37 +- stellar_sdk/xdr/ip_addr_type.py | 11 +- stellar_sdk/xdr/ledger_bounds.py | 33 +- stellar_sdk/xdr/ledger_close_meta.py | 42 +- stellar_sdk/xdr/ledger_close_meta_v0.py | 62 +- stellar_sdk/xdr/ledger_close_meta_v1.py | 62 +- stellar_sdk/xdr/ledger_close_meta_v2.py | 109 +- .../xdr/ledger_close_value_signature.py | 30 +- stellar_sdk/xdr/ledger_entry.py | 39 +- stellar_sdk/xdr/ledger_entry_change.py | 49 +- stellar_sdk/xdr/ledger_entry_change_type.py | 11 +- stellar_sdk/xdr/ledger_entry_changes.py | 25 +- stellar_sdk/xdr/ledger_entry_data.py | 97 +- stellar_sdk/xdr/ledger_entry_ext.py | 31 +- stellar_sdk/xdr/ledger_entry_extension_v1.py | 32 +- .../xdr/ledger_entry_extension_v1_ext.py | 22 +- stellar_sdk/xdr/ledger_entry_type.py | 11 +- stellar_sdk/xdr/ledger_footprint.py | 40 +- stellar_sdk/xdr/ledger_header.py | 103 +- stellar_sdk/xdr/ledger_header_ext.py | 31 +- stellar_sdk/xdr/ledger_header_extension_v1.py | 32 +- .../xdr/ledger_header_extension_v1_ext.py | 22 +- stellar_sdk/xdr/ledger_header_flags.py | 11 +- .../xdr/ledger_header_history_entry.py | 37 +- .../xdr/ledger_header_history_entry_ext.py | 22 +- stellar_sdk/xdr/ledger_key.py | 95 +- stellar_sdk/xdr/ledger_key_account.py | 21 +- .../xdr/ledger_key_claimable_balance.py | 21 +- stellar_sdk/xdr/ledger_key_config_setting.py | 21 +- stellar_sdk/xdr/ledger_key_contract_code.py | 21 +- stellar_sdk/xdr/ledger_key_contract_data.py | 39 +- stellar_sdk/xdr/ledger_key_data.py | 30 +- stellar_sdk/xdr/ledger_key_expiration.py | 65 + stellar_sdk/xdr/ledger_key_liquidity_pool.py | 21 +- stellar_sdk/xdr/ledger_key_offer.py | 30 +- stellar_sdk/xdr/ledger_key_trust_line.py | 30 +- stellar_sdk/xdr/ledger_scp_messages.py | 37 +- stellar_sdk/xdr/ledger_upgrade.py | 82 +- stellar_sdk/xdr/ledger_upgrade_type.py | 11 +- stellar_sdk/xdr/liabilities.py | 31 +- ...uidity_pool_constant_product_parameters.py | 38 +- stellar_sdk/xdr/liquidity_pool_deposit_op.py | 49 +- .../xdr/liquidity_pool_deposit_result.py | 31 +- .../xdr/liquidity_pool_deposit_result_code.py | 11 +- stellar_sdk/xdr/liquidity_pool_entry.py | 35 +- stellar_sdk/xdr/liquidity_pool_entry_body.py | 36 +- .../liquidity_pool_entry_constant_product.py | 52 +- stellar_sdk/xdr/liquidity_pool_parameters.py | 38 +- stellar_sdk/xdr/liquidity_pool_type.py | 11 +- stellar_sdk/xdr/liquidity_pool_withdraw_op.py | 45 +- .../xdr/liquidity_pool_withdraw_result.py | 51 +- .../liquidity_pool_withdraw_result_code.py | 11 +- stellar_sdk/xdr/manage_buy_offer_op.py | 47 +- stellar_sdk/xdr/manage_buy_offer_result.py | 30 +- .../xdr/manage_buy_offer_result_code.py | 11 +- stellar_sdk/xdr/manage_data_op.py | 33 +- stellar_sdk/xdr/manage_data_result.py | 21 +- stellar_sdk/xdr/manage_data_result_code.py | 11 +- stellar_sdk/xdr/manage_offer_effect.py | 11 +- .../xdr/manage_offer_success_result.py | 35 +- .../xdr/manage_offer_success_result_offer.py | 30 +- stellar_sdk/xdr/manage_sell_offer_op.py | 47 +- stellar_sdk/xdr/manage_sell_offer_result.py | 32 +- .../xdr/manage_sell_offer_result_code.py | 11 +- stellar_sdk/xdr/memo.py | 49 +- stellar_sdk/xdr/memo_type.py | 11 +- stellar_sdk/xdr/message_type.py | 11 +- stellar_sdk/xdr/muxed_account.py | 39 +- stellar_sdk/xdr/muxed_account_med25519.py | 30 +- stellar_sdk/xdr/node_id.py | 16 +- stellar_sdk/xdr/offer_entry.py | 61 +- stellar_sdk/xdr/offer_entry_ext.py | 22 +- stellar_sdk/xdr/offer_entry_flags.py | 11 +- stellar_sdk/xdr/operation.py | 35 +- stellar_sdk/xdr/operation_body.py | 257 +-- stellar_sdk/xdr/operation_meta.py | 21 +- stellar_sdk/xdr/operation_result.py | 30 +- stellar_sdk/xdr/operation_result_code.py | 11 +- stellar_sdk/xdr/operation_result_tr.py | 363 +--- stellar_sdk/xdr/operation_type.py | 11 +- .../xdr/path_payment_strict_receive_op.py | 57 +- .../xdr/path_payment_strict_receive_result.py | 175 +- ...path_payment_strict_receive_result_code.py | 11 +- ...h_payment_strict_receive_result_success.py | 35 +- .../xdr/path_payment_strict_send_op.py | 57 +- .../xdr/path_payment_strict_send_result.py | 141 +- .../path_payment_strict_send_result_code.py | 11 +- ...path_payment_strict_send_result_success.py | 35 +- stellar_sdk/xdr/payment_op.py | 39 +- stellar_sdk/xdr/payment_result.py | 21 +- stellar_sdk/xdr/payment_result_code.py | 11 +- stellar_sdk/xdr/peer_address.py | 38 +- stellar_sdk/xdr/peer_address_ip.py | 38 +- stellar_sdk/xdr/peer_stat_list.py | 21 +- stellar_sdk/xdr/peer_stats.py | 98 +- stellar_sdk/xdr/persisted_scp_state.py | 48 +- stellar_sdk/xdr/persisted_scp_state_v0.py | 62 +- stellar_sdk/xdr/persisted_scp_state_v1.py | 54 +- stellar_sdk/xdr/pool_id.py | 16 +- stellar_sdk/xdr/precondition_type.py | 11 +- stellar_sdk/xdr/preconditions.py | 41 +- stellar_sdk/xdr/preconditions_v2.py | 68 +- stellar_sdk/xdr/price.py | 31 +- stellar_sdk/xdr/public_key.py | 30 +- stellar_sdk/xdr/public_key_type.py | 11 +- stellar_sdk/xdr/restore_footprint_op.py | 21 +- stellar_sdk/xdr/restore_footprint_result.py | 36 +- .../xdr/restore_footprint_result_code.py | 11 +- stellar_sdk/xdr/revoke_sponsorship_op.py | 41 +- .../xdr/revoke_sponsorship_op_signer.py | 32 +- stellar_sdk/xdr/revoke_sponsorship_result.py | 26 +- .../xdr/revoke_sponsorship_result_code.py | 11 +- stellar_sdk/xdr/revoke_sponsorship_type.py | 11 +- stellar_sdk/xdr/sc_address.py | 43 +- stellar_sdk/xdr/sc_address_type.py | 11 +- stellar_sdk/xdr/sc_bytes.py | 17 +- stellar_sdk/xdr/sc_contract_instance.py | 31 +- stellar_sdk/xdr/sc_env_meta_entry.py | 35 +- stellar_sdk/xdr/sc_env_meta_kind.py | 11 +- stellar_sdk/xdr/sc_error.py | 41 +- stellar_sdk/xdr/sc_error_code.py | 11 +- stellar_sdk/xdr/sc_error_type.py | 11 +- stellar_sdk/xdr/sc_map.py | 21 +- stellar_sdk/xdr/sc_map_entry.py | 31 +- stellar_sdk/xdr/sc_meta_entry.py | 30 +- stellar_sdk/xdr/sc_meta_kind.py | 11 +- stellar_sdk/xdr/sc_meta_v0.py | 31 +- stellar_sdk/xdr/sc_nonce_key.py | 21 +- stellar_sdk/xdr/sc_spec_entry.py | 63 +- stellar_sdk/xdr/sc_spec_entry_kind.py | 11 +- stellar_sdk/xdr/sc_spec_function_input_v0.py | 39 +- stellar_sdk/xdr/sc_spec_function_v0.py | 54 +- stellar_sdk/xdr/sc_spec_type.py | 11 +- stellar_sdk/xdr/sc_spec_type_bytes_n.py | 21 +- stellar_sdk/xdr/sc_spec_type_def.py | 71 +- stellar_sdk/xdr/sc_spec_type_map.py | 31 +- stellar_sdk/xdr/sc_spec_type_option.py | 21 +- stellar_sdk/xdr/sc_spec_type_result.py | 31 +- stellar_sdk/xdr/sc_spec_type_tuple.py | 26 +- stellar_sdk/xdr/sc_spec_type_udt.py | 22 +- stellar_sdk/xdr/sc_spec_type_vec.py | 21 +- stellar_sdk/xdr/sc_spec_udt_enum_case_v0.py | 39 +- stellar_sdk/xdr/sc_spec_udt_enum_v0.py | 48 +- .../xdr/sc_spec_udt_error_enum_case_v0.py | 39 +- stellar_sdk/xdr/sc_spec_udt_error_enum_v0.py | 48 +- .../xdr/sc_spec_udt_struct_field_v0.py | 39 +- stellar_sdk/xdr/sc_spec_udt_struct_v0.py | 48 +- .../xdr/sc_spec_udt_union_case_tuple_v0.py | 44 +- stellar_sdk/xdr/sc_spec_udt_union_case_v0.py | 43 +- .../xdr/sc_spec_udt_union_case_v0_kind.py | 11 +- .../xdr/sc_spec_udt_union_case_void_v0.py | 30 +- stellar_sdk/xdr/sc_spec_udt_union_v0.py | 48 +- stellar_sdk/xdr/sc_string.py | 17 +- stellar_sdk/xdr/sc_symbol.py | 16 +- stellar_sdk/xdr/sc_val.py | 156 +- stellar_sdk/xdr/sc_val_type.py | 13 +- stellar_sdk/xdr/sc_vec.py | 21 +- stellar_sdk/xdr/scp_ballot.py | 30 +- stellar_sdk/xdr/scp_envelope.py | 30 +- stellar_sdk/xdr/scp_history_entry.py | 31 +- stellar_sdk/xdr/scp_history_entry_v0.py | 40 +- stellar_sdk/xdr/scp_nomination.py | 47 +- stellar_sdk/xdr/scp_quorum_set.py | 48 +- stellar_sdk/xdr/scp_statement.py | 39 +- stellar_sdk/xdr/scp_statement_confirm.py | 49 +- stellar_sdk/xdr/scp_statement_externalize.py | 39 +- stellar_sdk/xdr/scp_statement_pledges.py | 53 +- stellar_sdk/xdr/scp_statement_prepare.py | 53 +- stellar_sdk/xdr/scp_statement_type.py | 11 +- stellar_sdk/xdr/send_more.py | 21 +- stellar_sdk/xdr/send_more_extended.py | 34 +- stellar_sdk/xdr/sequence_number.py | 16 +- stellar_sdk/xdr/set_options_op.py | 71 +- stellar_sdk/xdr/set_options_result.py | 21 +- stellar_sdk/xdr/set_options_result_code.py | 11 +- stellar_sdk/xdr/set_trust_line_flags_op.py | 42 +- .../xdr/set_trust_line_flags_result.py | 21 +- .../xdr/set_trust_line_flags_result_code.py | 11 +- stellar_sdk/xdr/signature.py | 17 +- stellar_sdk/xdr/signature_hint.py | 17 +- .../xdr/signed_survey_request_message.py | 33 +- .../xdr/signed_survey_response_message.py | 33 +- stellar_sdk/xdr/signer.py | 30 +- stellar_sdk/xdr/signer_key.py | 53 +- .../xdr/signer_key_ed25519_signed_payload.py | 31 +- stellar_sdk/xdr/signer_key_type.py | 11 +- stellar_sdk/xdr/simple_payment_result.py | 37 +- .../xdr/soroban_address_credentials.py | 47 +- .../xdr/soroban_authorization_entry.py | 35 +- .../xdr/soroban_authorized_function.py | 65 +- .../xdr/soroban_authorized_function_type.py | 11 +- .../xdr/soroban_authorized_invocation.py | 38 +- stellar_sdk/xdr/soroban_credentials.py | 32 +- stellar_sdk/xdr/soroban_credentials_type.py | 11 +- stellar_sdk/xdr/soroban_resources.py | 47 +- stellar_sdk/xdr/soroban_transaction_data.py | 39 +- stellar_sdk/xdr/soroban_transaction_meta.py | 56 +- stellar_sdk/xdr/sponsorship_descriptor.py | 21 +- stellar_sdk/xdr/state_expiration_settings.py | 70 +- stellar_sdk/xdr/stellar_message.py | 175 +- stellar_sdk/xdr/stellar_value.py | 48 +- stellar_sdk/xdr/stellar_value_ext.py | 34 +- stellar_sdk/xdr/stellar_value_type.py | 11 +- stellar_sdk/xdr/stored_transaction_set.py | 56 +- stellar_sdk/xdr/string32.py | 17 +- stellar_sdk/xdr/string64.py | 17 +- .../xdr/survey_message_command_type.py | 11 +- .../xdr/survey_message_response_type.py | 11 +- stellar_sdk/xdr/survey_request_message.py | 50 +- stellar_sdk/xdr/survey_response_body.py | 41 +- stellar_sdk/xdr/survey_response_message.py | 50 +- stellar_sdk/xdr/threshold_indexes.py | 11 +- stellar_sdk/xdr/thresholds.py | 17 +- stellar_sdk/xdr/time_bounds.py | 31 +- stellar_sdk/xdr/time_point.py | 16 +- stellar_sdk/xdr/topology_response_body_v0.py | 43 +- stellar_sdk/xdr/topology_response_body_v1.py | 53 +- stellar_sdk/xdr/transaction.py | 67 +- stellar_sdk/xdr/transaction_envelope.py | 43 +- stellar_sdk/xdr/transaction_ext.py | 33 +- stellar_sdk/xdr/transaction_history_entry.py | 41 +- .../xdr/transaction_history_entry_ext.py | 33 +- .../xdr/transaction_history_result_entry.py | 41 +- .../transaction_history_result_entry_ext.py | 22 +- stellar_sdk/xdr/transaction_meta.py | 53 +- stellar_sdk/xdr/transaction_meta_v1.py | 37 +- stellar_sdk/xdr/transaction_meta_v2.py | 43 +- stellar_sdk/xdr/transaction_meta_v3.py | 57 +- stellar_sdk/xdr/transaction_phase.py | 38 +- stellar_sdk/xdr/transaction_result.py | 39 +- stellar_sdk/xdr/transaction_result_code.py | 11 +- stellar_sdk/xdr/transaction_result_ext.py | 22 +- stellar_sdk/xdr/transaction_result_meta.py | 39 +- stellar_sdk/xdr/transaction_result_pair.py | 33 +- stellar_sdk/xdr/transaction_result_result.py | 46 +- stellar_sdk/xdr/transaction_result_set.py | 26 +- stellar_sdk/xdr/transaction_set.py | 38 +- stellar_sdk/xdr/transaction_set_v1.py | 38 +- .../xdr/transaction_signature_payload.py | 41 +- ...on_signature_payload_tagged_transaction.py | 39 +- stellar_sdk/xdr/transaction_v0.py | 67 +- stellar_sdk/xdr/transaction_v0_envelope.py | 37 +- stellar_sdk/xdr/transaction_v0_ext.py | 22 +- stellar_sdk/xdr/transaction_v1_envelope.py | 37 +- stellar_sdk/xdr/trust_line_asset.py | 49 +- stellar_sdk/xdr/trust_line_entry.py | 54 +- stellar_sdk/xdr/trust_line_entry_ext.py | 31 +- .../xdr/trust_line_entry_extension_v2.py | 33 +- .../xdr/trust_line_entry_extension_v2_ext.py | 22 +- stellar_sdk/xdr/trust_line_entry_v1.py | 30 +- stellar_sdk/xdr/trust_line_entry_v1_ext.py | 31 +- stellar_sdk/xdr/trust_line_flags.py | 11 +- stellar_sdk/xdr/tx_advert_vector.py | 22 +- stellar_sdk/xdr/tx_demand_vector.py | 22 +- stellar_sdk/xdr/tx_set_component.py | 43 +- ..._set_component_txs_maybe_discounted_fee.py | 35 +- stellar_sdk/xdr/tx_set_component_type.py | 11 +- stellar_sdk/xdr/u_int128_parts.py | 31 +- stellar_sdk/xdr/u_int256_parts.py | 44 +- stellar_sdk/xdr/uint256.py | 17 +- stellar_sdk/xdr/uint32.py | 17 +- stellar_sdk/xdr/uint64.py | 17 +- stellar_sdk/xdr/upgrade_entry_meta.py | 32 +- stellar_sdk/xdr/upgrade_type.py | 17 +- stellar_sdk/xdr/value.py | 17 +- 422 files changed, 4945 insertions(+), 12521 deletions(-) create mode 100644 stellar_sdk/xdr/config_setting_contract_events_v0.py create mode 100644 stellar_sdk/xdr/eviction_iterator.py create mode 100644 stellar_sdk/xdr/expiration_entry.py create mode 100644 stellar_sdk/xdr/invoke_contract_args.py create mode 100644 stellar_sdk/xdr/ledger_key_expiration.py diff --git a/Makefile b/Makefile index c7d49c0a..6a8a0b43 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ XDRNEXT_COMMIT=9ac02641139e6717924fdad716f6e958d0168491 UNAME := $(shell uname) SED := sed ifeq ($(UNAME), Darwin) - SED := sed -i '' + SED := sed -i endif # default target does nothing @@ -79,7 +79,7 @@ xdr-generate: $(XDRS) --output stellar_sdk/xdr \ $(XDRS)' $(SED) '/stellar_sdk\.xdr/,$$d' docs/en/api.rst - python docs/gen_xdr_api.py >> docs/en/api.rst + python3 docs/gen_xdr_api.py >> docs/en/api.rst .PHONY: xdr-generate xdr/%.x: diff --git a/docs/en/api.rst b/docs/en/api.rst index cbf29c88..40434ee7 100644 --- a/docs/en/api.rst +++ b/docs/en/api.rst @@ -871,1746 +871,3 @@ Exceptions .. _stellar_sdk_xdr: -stellar_sdk.xdr -^^^^^^^^^^^^^^^ - -AccountEntry ------------- -.. autoclass:: stellar_sdk.xdr.account_entry.AccountEntry - -AccountEntryExt ---------------- -.. autoclass:: stellar_sdk.xdr.account_entry_ext.AccountEntryExt - -AccountEntryExtensionV1 ------------------------ -.. autoclass:: stellar_sdk.xdr.account_entry_extension_v1.AccountEntryExtensionV1 - -AccountEntryExtensionV1Ext --------------------------- -.. autoclass:: stellar_sdk.xdr.account_entry_extension_v1_ext.AccountEntryExtensionV1Ext - -AccountEntryExtensionV2 ------------------------ -.. autoclass:: stellar_sdk.xdr.account_entry_extension_v2.AccountEntryExtensionV2 - -AccountEntryExtensionV2Ext --------------------------- -.. autoclass:: stellar_sdk.xdr.account_entry_extension_v2_ext.AccountEntryExtensionV2Ext - -AccountEntryExtensionV3 ------------------------ -.. autoclass:: stellar_sdk.xdr.account_entry_extension_v3.AccountEntryExtensionV3 - -AccountFlags ------------- -.. autoclass:: stellar_sdk.xdr.account_flags.AccountFlags - -AccountID ---------- -.. autoclass:: stellar_sdk.xdr.account_id.AccountID - -AccountMergeResult ------------------- -.. autoclass:: stellar_sdk.xdr.account_merge_result.AccountMergeResult - -AccountMergeResultCode ----------------------- -.. autoclass:: stellar_sdk.xdr.account_merge_result_code.AccountMergeResultCode - -AllowTrustOp ------------- -.. autoclass:: stellar_sdk.xdr.allow_trust_op.AllowTrustOp - -AllowTrustResult ----------------- -.. autoclass:: stellar_sdk.xdr.allow_trust_result.AllowTrustResult - -AllowTrustResultCode --------------------- -.. autoclass:: stellar_sdk.xdr.allow_trust_result_code.AllowTrustResultCode - -AlphaNum12 ----------- -.. autoclass:: stellar_sdk.xdr.alpha_num12.AlphaNum12 - -AlphaNum4 ---------- -.. autoclass:: stellar_sdk.xdr.alpha_num4.AlphaNum4 - -Asset ------ -.. autoclass:: stellar_sdk.xdr.asset.Asset - -AssetCode ---------- -.. autoclass:: stellar_sdk.xdr.asset_code.AssetCode - -AssetCode12 ------------ -.. autoclass:: stellar_sdk.xdr.asset_code12.AssetCode12 - -AssetCode4 ----------- -.. autoclass:: stellar_sdk.xdr.asset_code4.AssetCode4 - -AssetType ---------- -.. autoclass:: stellar_sdk.xdr.asset_type.AssetType - -Auth ----- -.. autoclass:: stellar_sdk.xdr.auth.Auth - -AuthCert --------- -.. autoclass:: stellar_sdk.xdr.auth_cert.AuthCert - -AuthenticatedMessage --------------------- -.. autoclass:: stellar_sdk.xdr.authenticated_message.AuthenticatedMessage - -AuthenticatedMessageV0 ----------------------- -.. autoclass:: stellar_sdk.xdr.authenticated_message_v0.AuthenticatedMessageV0 - -BeginSponsoringFutureReservesOp -------------------------------- -.. autoclass:: stellar_sdk.xdr.begin_sponsoring_future_reserves_op.BeginSponsoringFutureReservesOp - -BeginSponsoringFutureReservesResult ------------------------------------ -.. autoclass:: stellar_sdk.xdr.begin_sponsoring_future_reserves_result.BeginSponsoringFutureReservesResult - -BeginSponsoringFutureReservesResultCode ---------------------------------------- -.. autoclass:: stellar_sdk.xdr.begin_sponsoring_future_reserves_result_code.BeginSponsoringFutureReservesResultCode - -Boolean -------- -.. autoclass:: stellar_sdk.xdr.base.Boolean - -BucketEntry ------------ -.. autoclass:: stellar_sdk.xdr.bucket_entry.BucketEntry - -BucketEntryType ---------------- -.. autoclass:: stellar_sdk.xdr.bucket_entry_type.BucketEntryType - -BucketMetadata --------------- -.. autoclass:: stellar_sdk.xdr.bucket_metadata.BucketMetadata - -BucketMetadataExt ------------------ -.. autoclass:: stellar_sdk.xdr.bucket_metadata_ext.BucketMetadataExt - -BumpFootprintExpirationOp -------------------------- -.. autoclass:: stellar_sdk.xdr.bump_footprint_expiration_op.BumpFootprintExpirationOp - -BumpFootprintExpirationResult ------------------------------ -.. autoclass:: stellar_sdk.xdr.bump_footprint_expiration_result.BumpFootprintExpirationResult - -BumpFootprintExpirationResultCode ---------------------------------- -.. autoclass:: stellar_sdk.xdr.bump_footprint_expiration_result_code.BumpFootprintExpirationResultCode - -BumpSequenceOp --------------- -.. autoclass:: stellar_sdk.xdr.bump_sequence_op.BumpSequenceOp - -BumpSequenceResult ------------------- -.. autoclass:: stellar_sdk.xdr.bump_sequence_result.BumpSequenceResult - -BumpSequenceResultCode ----------------------- -.. autoclass:: stellar_sdk.xdr.bump_sequence_result_code.BumpSequenceResultCode - -ChangeTrustAsset ----------------- -.. autoclass:: stellar_sdk.xdr.change_trust_asset.ChangeTrustAsset - -ChangeTrustOp -------------- -.. autoclass:: stellar_sdk.xdr.change_trust_op.ChangeTrustOp - -ChangeTrustResult ------------------ -.. autoclass:: stellar_sdk.xdr.change_trust_result.ChangeTrustResult - -ChangeTrustResultCode ---------------------- -.. autoclass:: stellar_sdk.xdr.change_trust_result_code.ChangeTrustResultCode - -ClaimAtom ---------- -.. autoclass:: stellar_sdk.xdr.claim_atom.ClaimAtom - -ClaimAtomType -------------- -.. autoclass:: stellar_sdk.xdr.claim_atom_type.ClaimAtomType - -ClaimClaimableBalanceOp ------------------------ -.. autoclass:: stellar_sdk.xdr.claim_claimable_balance_op.ClaimClaimableBalanceOp - -ClaimClaimableBalanceResult ---------------------------- -.. autoclass:: stellar_sdk.xdr.claim_claimable_balance_result.ClaimClaimableBalanceResult - -ClaimClaimableBalanceResultCode -------------------------------- -.. autoclass:: stellar_sdk.xdr.claim_claimable_balance_result_code.ClaimClaimableBalanceResultCode - -ClaimLiquidityAtom ------------------- -.. autoclass:: stellar_sdk.xdr.claim_liquidity_atom.ClaimLiquidityAtom - -ClaimOfferAtom --------------- -.. autoclass:: stellar_sdk.xdr.claim_offer_atom.ClaimOfferAtom - -ClaimOfferAtomV0 ----------------- -.. autoclass:: stellar_sdk.xdr.claim_offer_atom_v0.ClaimOfferAtomV0 - -ClaimPredicate --------------- -.. autoclass:: stellar_sdk.xdr.claim_predicate.ClaimPredicate - -ClaimPredicateType ------------------- -.. autoclass:: stellar_sdk.xdr.claim_predicate_type.ClaimPredicateType - -ClaimableBalanceEntry ---------------------- -.. autoclass:: stellar_sdk.xdr.claimable_balance_entry.ClaimableBalanceEntry - -ClaimableBalanceEntryExt ------------------------- -.. autoclass:: stellar_sdk.xdr.claimable_balance_entry_ext.ClaimableBalanceEntryExt - -ClaimableBalanceEntryExtensionV1 --------------------------------- -.. autoclass:: stellar_sdk.xdr.claimable_balance_entry_extension_v1.ClaimableBalanceEntryExtensionV1 - -ClaimableBalanceEntryExtensionV1Ext ------------------------------------ -.. autoclass:: stellar_sdk.xdr.claimable_balance_entry_extension_v1_ext.ClaimableBalanceEntryExtensionV1Ext - -ClaimableBalanceFlags ---------------------- -.. autoclass:: stellar_sdk.xdr.claimable_balance_flags.ClaimableBalanceFlags - -ClaimableBalanceID ------------------- -.. autoclass:: stellar_sdk.xdr.claimable_balance_id.ClaimableBalanceID - -ClaimableBalanceIDType ----------------------- -.. autoclass:: stellar_sdk.xdr.claimable_balance_id_type.ClaimableBalanceIDType - -Claimant --------- -.. autoclass:: stellar_sdk.xdr.claimant.Claimant - -ClaimantType ------------- -.. autoclass:: stellar_sdk.xdr.claimant_type.ClaimantType - -ClaimantV0 ----------- -.. autoclass:: stellar_sdk.xdr.claimant_v0.ClaimantV0 - -ClawbackClaimableBalanceOp --------------------------- -.. autoclass:: stellar_sdk.xdr.clawback_claimable_balance_op.ClawbackClaimableBalanceOp - -ClawbackClaimableBalanceResult ------------------------------- -.. autoclass:: stellar_sdk.xdr.clawback_claimable_balance_result.ClawbackClaimableBalanceResult - -ClawbackClaimableBalanceResultCode ----------------------------------- -.. autoclass:: stellar_sdk.xdr.clawback_claimable_balance_result_code.ClawbackClaimableBalanceResultCode - -ClawbackOp ----------- -.. autoclass:: stellar_sdk.xdr.clawback_op.ClawbackOp - -ClawbackResult --------------- -.. autoclass:: stellar_sdk.xdr.clawback_result.ClawbackResult - -ClawbackResultCode ------------------- -.. autoclass:: stellar_sdk.xdr.clawback_result_code.ClawbackResultCode - -ConfigSettingContractBandwidthV0 --------------------------------- -.. autoclass:: stellar_sdk.xdr.config_setting_contract_bandwidth_v0.ConfigSettingContractBandwidthV0 - -ConfigSettingContractComputeV0 ------------------------------- -.. autoclass:: stellar_sdk.xdr.config_setting_contract_compute_v0.ConfigSettingContractComputeV0 - -ConfigSettingContractExecutionLanesV0 -------------------------------------- -.. autoclass:: stellar_sdk.xdr.config_setting_contract_execution_lanes_v0.ConfigSettingContractExecutionLanesV0 - -ConfigSettingContractHistoricalDataV0 -------------------------------------- -.. autoclass:: stellar_sdk.xdr.config_setting_contract_historical_data_v0.ConfigSettingContractHistoricalDataV0 - -ConfigSettingContractLedgerCostV0 ---------------------------------- -.. autoclass:: stellar_sdk.xdr.config_setting_contract_ledger_cost_v0.ConfigSettingContractLedgerCostV0 - -ConfigSettingContractMetaDataV0 -------------------------------- -.. autoclass:: stellar_sdk.xdr.config_setting_contract_meta_data_v0.ConfigSettingContractMetaDataV0 - -ConfigSettingEntry ------------------- -.. autoclass:: stellar_sdk.xdr.config_setting_entry.ConfigSettingEntry - -ConfigSettingID ---------------- -.. autoclass:: stellar_sdk.xdr.config_setting_id.ConfigSettingID - -ConfigUpgradeSet ----------------- -.. autoclass:: stellar_sdk.xdr.config_upgrade_set.ConfigUpgradeSet - -ConfigUpgradeSetKey -------------------- -.. autoclass:: stellar_sdk.xdr.config_upgrade_set_key.ConfigUpgradeSetKey - -ContractCodeEntry ------------------ -.. autoclass:: stellar_sdk.xdr.contract_code_entry.ContractCodeEntry - -ContractCodeEntryBody ---------------------- -.. autoclass:: stellar_sdk.xdr.contract_code_entry_body.ContractCodeEntryBody - -ContractCostParamEntry ----------------------- -.. autoclass:: stellar_sdk.xdr.contract_cost_param_entry.ContractCostParamEntry - -ContractCostParams ------------------- -.. autoclass:: stellar_sdk.xdr.contract_cost_params.ContractCostParams - -ContractCostType ----------------- -.. autoclass:: stellar_sdk.xdr.contract_cost_type.ContractCostType - -ContractDataDurability ----------------------- -.. autoclass:: stellar_sdk.xdr.contract_data_durability.ContractDataDurability - -ContractDataEntry ------------------ -.. autoclass:: stellar_sdk.xdr.contract_data_entry.ContractDataEntry - -ContractDataEntryBody ---------------------- -.. autoclass:: stellar_sdk.xdr.contract_data_entry_body.ContractDataEntryBody - -ContractDataEntryData ---------------------- -.. autoclass:: stellar_sdk.xdr.contract_data_entry_data.ContractDataEntryData - -ContractDataFlags ------------------ -.. autoclass:: stellar_sdk.xdr.contract_data_flags.ContractDataFlags - -ContractEntryBodyType ---------------------- -.. autoclass:: stellar_sdk.xdr.contract_entry_body_type.ContractEntryBodyType - -ContractEvent -------------- -.. autoclass:: stellar_sdk.xdr.contract_event.ContractEvent - -ContractEventBody ------------------ -.. autoclass:: stellar_sdk.xdr.contract_event_body.ContractEventBody - -ContractEventType ------------------ -.. autoclass:: stellar_sdk.xdr.contract_event_type.ContractEventType - -ContractEventV0 ---------------- -.. autoclass:: stellar_sdk.xdr.contract_event_v0.ContractEventV0 - -ContractExecutable ------------------- -.. autoclass:: stellar_sdk.xdr.contract_executable.ContractExecutable - -ContractExecutableType ----------------------- -.. autoclass:: stellar_sdk.xdr.contract_executable_type.ContractExecutableType - -ContractIDPreimage ------------------- -.. autoclass:: stellar_sdk.xdr.contract_id_preimage.ContractIDPreimage - -ContractIDPreimageFromAddress ------------------------------ -.. autoclass:: stellar_sdk.xdr.contract_id_preimage_from_address.ContractIDPreimageFromAddress - -ContractIDPreimageType ----------------------- -.. autoclass:: stellar_sdk.xdr.contract_id_preimage_type.ContractIDPreimageType - -CreateAccountOp ---------------- -.. autoclass:: stellar_sdk.xdr.create_account_op.CreateAccountOp - -CreateAccountResult -------------------- -.. autoclass:: stellar_sdk.xdr.create_account_result.CreateAccountResult - -CreateAccountResultCode ------------------------ -.. autoclass:: stellar_sdk.xdr.create_account_result_code.CreateAccountResultCode - -CreateClaimableBalanceOp ------------------------- -.. autoclass:: stellar_sdk.xdr.create_claimable_balance_op.CreateClaimableBalanceOp - -CreateClaimableBalanceResult ----------------------------- -.. autoclass:: stellar_sdk.xdr.create_claimable_balance_result.CreateClaimableBalanceResult - -CreateClaimableBalanceResultCode --------------------------------- -.. autoclass:: stellar_sdk.xdr.create_claimable_balance_result_code.CreateClaimableBalanceResultCode - -CreateContractArgs ------------------- -.. autoclass:: stellar_sdk.xdr.create_contract_args.CreateContractArgs - -CreatePassiveSellOfferOp ------------------------- -.. autoclass:: stellar_sdk.xdr.create_passive_sell_offer_op.CreatePassiveSellOfferOp - -CryptoKeyType -------------- -.. autoclass:: stellar_sdk.xdr.crypto_key_type.CryptoKeyType - -Curve25519Public ----------------- -.. autoclass:: stellar_sdk.xdr.curve25519_public.Curve25519Public - -Curve25519Secret ----------------- -.. autoclass:: stellar_sdk.xdr.curve25519_secret.Curve25519Secret - -DataEntry ---------- -.. autoclass:: stellar_sdk.xdr.data_entry.DataEntry - -DataEntryExt ------------- -.. autoclass:: stellar_sdk.xdr.data_entry_ext.DataEntryExt - -DataValue ---------- -.. autoclass:: stellar_sdk.xdr.data_value.DataValue - -DecoratedSignature ------------------- -.. autoclass:: stellar_sdk.xdr.decorated_signature.DecoratedSignature - -DiagnosticEvent ---------------- -.. autoclass:: stellar_sdk.xdr.diagnostic_event.DiagnosticEvent - -DontHave --------- -.. autoclass:: stellar_sdk.xdr.dont_have.DontHave - -Double ------- -.. autoclass:: stellar_sdk.xdr.base.Double - -Duration --------- -.. autoclass:: stellar_sdk.xdr.duration.Duration - -EncryptedBody -------------- -.. autoclass:: stellar_sdk.xdr.encrypted_body.EncryptedBody - -EndSponsoringFutureReservesResult ---------------------------------- -.. autoclass:: stellar_sdk.xdr.end_sponsoring_future_reserves_result.EndSponsoringFutureReservesResult - -EndSponsoringFutureReservesResultCode -------------------------------------- -.. autoclass:: stellar_sdk.xdr.end_sponsoring_future_reserves_result_code.EndSponsoringFutureReservesResultCode - -EnvelopeType ------------- -.. autoclass:: stellar_sdk.xdr.envelope_type.EnvelopeType - -Error ------ -.. autoclass:: stellar_sdk.xdr.error.Error - -ErrorCode ---------- -.. autoclass:: stellar_sdk.xdr.error_code.ErrorCode - -ExtensionPoint --------------- -.. autoclass:: stellar_sdk.xdr.extension_point.ExtensionPoint - -FeeBumpTransaction ------------------- -.. autoclass:: stellar_sdk.xdr.fee_bump_transaction.FeeBumpTransaction - -FeeBumpTransactionEnvelope --------------------------- -.. autoclass:: stellar_sdk.xdr.fee_bump_transaction_envelope.FeeBumpTransactionEnvelope - -FeeBumpTransactionExt ---------------------- -.. autoclass:: stellar_sdk.xdr.fee_bump_transaction_ext.FeeBumpTransactionExt - -FeeBumpTransactionInnerTx -------------------------- -.. autoclass:: stellar_sdk.xdr.fee_bump_transaction_inner_tx.FeeBumpTransactionInnerTx - -Float ------ -.. autoclass:: stellar_sdk.xdr.base.Float - -FloodAdvert ------------ -.. autoclass:: stellar_sdk.xdr.flood_advert.FloodAdvert - -FloodDemand ------------ -.. autoclass:: stellar_sdk.xdr.flood_demand.FloodDemand - -GeneralizedTransactionSet -------------------------- -.. autoclass:: stellar_sdk.xdr.generalized_transaction_set.GeneralizedTransactionSet - -Hash ----- -.. autoclass:: stellar_sdk.xdr.hash.Hash - -HashIDPreimage --------------- -.. autoclass:: stellar_sdk.xdr.hash_id_preimage.HashIDPreimage - -HashIDPreimageContractID ------------------------- -.. autoclass:: stellar_sdk.xdr.hash_id_preimage_contract_id.HashIDPreimageContractID - -HashIDPreimageOperationID -------------------------- -.. autoclass:: stellar_sdk.xdr.hash_id_preimage_operation_id.HashIDPreimageOperationID - -HashIDPreimageRevokeID ----------------------- -.. autoclass:: stellar_sdk.xdr.hash_id_preimage_revoke_id.HashIDPreimageRevokeID - -HashIDPreimageSorobanAuthorization ----------------------------------- -.. autoclass:: stellar_sdk.xdr.hash_id_preimage_soroban_authorization.HashIDPreimageSorobanAuthorization - -Hello ------ -.. autoclass:: stellar_sdk.xdr.hello.Hello - -HmacSha256Key -------------- -.. autoclass:: stellar_sdk.xdr.hmac_sha256_key.HmacSha256Key - -HmacSha256Mac -------------- -.. autoclass:: stellar_sdk.xdr.hmac_sha256_mac.HmacSha256Mac - -HostFunction ------------- -.. autoclass:: stellar_sdk.xdr.host_function.HostFunction - -HostFunctionType ----------------- -.. autoclass:: stellar_sdk.xdr.host_function_type.HostFunctionType - -Hyper ------ -.. autoclass:: stellar_sdk.xdr.base.Hyper - -IPAddrType ----------- -.. autoclass:: stellar_sdk.xdr.ip_addr_type.IPAddrType - -InflationPayout ---------------- -.. autoclass:: stellar_sdk.xdr.inflation_payout.InflationPayout - -InflationResult ---------------- -.. autoclass:: stellar_sdk.xdr.inflation_result.InflationResult - -InflationResultCode -------------------- -.. autoclass:: stellar_sdk.xdr.inflation_result_code.InflationResultCode - -InnerTransactionResult ----------------------- -.. autoclass:: stellar_sdk.xdr.inner_transaction_result.InnerTransactionResult - -InnerTransactionResultExt -------------------------- -.. autoclass:: stellar_sdk.xdr.inner_transaction_result_ext.InnerTransactionResultExt - -InnerTransactionResultPair --------------------------- -.. autoclass:: stellar_sdk.xdr.inner_transaction_result_pair.InnerTransactionResultPair - -InnerTransactionResultResult ----------------------------- -.. autoclass:: stellar_sdk.xdr.inner_transaction_result_result.InnerTransactionResultResult - -Int128Parts ------------ -.. autoclass:: stellar_sdk.xdr.int128_parts.Int128Parts - -Int256Parts ------------ -.. autoclass:: stellar_sdk.xdr.int256_parts.Int256Parts - -Int32 ------ -.. autoclass:: stellar_sdk.xdr.int32.Int32 - -Int64 ------ -.. autoclass:: stellar_sdk.xdr.int64.Int64 - -Integer -------- -.. autoclass:: stellar_sdk.xdr.base.Integer - -InvokeHostFunctionOp --------------------- -.. autoclass:: stellar_sdk.xdr.invoke_host_function_op.InvokeHostFunctionOp - -InvokeHostFunctionResult ------------------------- -.. autoclass:: stellar_sdk.xdr.invoke_host_function_result.InvokeHostFunctionResult - -InvokeHostFunctionResultCode ----------------------------- -.. autoclass:: stellar_sdk.xdr.invoke_host_function_result_code.InvokeHostFunctionResultCode - -InvokeHostFunctionSuccessPreImage ---------------------------------- -.. autoclass:: stellar_sdk.xdr.invoke_host_function_success_pre_image.InvokeHostFunctionSuccessPreImage - -LedgerBounds ------------- -.. autoclass:: stellar_sdk.xdr.ledger_bounds.LedgerBounds - -LedgerCloseMeta ---------------- -.. autoclass:: stellar_sdk.xdr.ledger_close_meta.LedgerCloseMeta - -LedgerCloseMetaV0 ------------------ -.. autoclass:: stellar_sdk.xdr.ledger_close_meta_v0.LedgerCloseMetaV0 - -LedgerCloseMetaV1 ------------------ -.. autoclass:: stellar_sdk.xdr.ledger_close_meta_v1.LedgerCloseMetaV1 - -LedgerCloseMetaV2 ------------------ -.. autoclass:: stellar_sdk.xdr.ledger_close_meta_v2.LedgerCloseMetaV2 - -LedgerCloseValueSignature -------------------------- -.. autoclass:: stellar_sdk.xdr.ledger_close_value_signature.LedgerCloseValueSignature - -LedgerEntry ------------ -.. autoclass:: stellar_sdk.xdr.ledger_entry.LedgerEntry - -LedgerEntryChange ------------------ -.. autoclass:: stellar_sdk.xdr.ledger_entry_change.LedgerEntryChange - -LedgerEntryChangeType ---------------------- -.. autoclass:: stellar_sdk.xdr.ledger_entry_change_type.LedgerEntryChangeType - -LedgerEntryChanges ------------------- -.. autoclass:: stellar_sdk.xdr.ledger_entry_changes.LedgerEntryChanges - -LedgerEntryData ---------------- -.. autoclass:: stellar_sdk.xdr.ledger_entry_data.LedgerEntryData - -LedgerEntryExt --------------- -.. autoclass:: stellar_sdk.xdr.ledger_entry_ext.LedgerEntryExt - -LedgerEntryExtensionV1 ----------------------- -.. autoclass:: stellar_sdk.xdr.ledger_entry_extension_v1.LedgerEntryExtensionV1 - -LedgerEntryExtensionV1Ext -------------------------- -.. autoclass:: stellar_sdk.xdr.ledger_entry_extension_v1_ext.LedgerEntryExtensionV1Ext - -LedgerEntryType ---------------- -.. autoclass:: stellar_sdk.xdr.ledger_entry_type.LedgerEntryType - -LedgerFootprint ---------------- -.. autoclass:: stellar_sdk.xdr.ledger_footprint.LedgerFootprint - -LedgerHeader ------------- -.. autoclass:: stellar_sdk.xdr.ledger_header.LedgerHeader - -LedgerHeaderExt ---------------- -.. autoclass:: stellar_sdk.xdr.ledger_header_ext.LedgerHeaderExt - -LedgerHeaderExtensionV1 ------------------------ -.. autoclass:: stellar_sdk.xdr.ledger_header_extension_v1.LedgerHeaderExtensionV1 - -LedgerHeaderExtensionV1Ext --------------------------- -.. autoclass:: stellar_sdk.xdr.ledger_header_extension_v1_ext.LedgerHeaderExtensionV1Ext - -LedgerHeaderFlags ------------------ -.. autoclass:: stellar_sdk.xdr.ledger_header_flags.LedgerHeaderFlags - -LedgerHeaderHistoryEntry ------------------------- -.. autoclass:: stellar_sdk.xdr.ledger_header_history_entry.LedgerHeaderHistoryEntry - -LedgerHeaderHistoryEntryExt ---------------------------- -.. autoclass:: stellar_sdk.xdr.ledger_header_history_entry_ext.LedgerHeaderHistoryEntryExt - -LedgerKey ---------- -.. autoclass:: stellar_sdk.xdr.ledger_key.LedgerKey - -LedgerKeyAccount ----------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_account.LedgerKeyAccount - -LedgerKeyClaimableBalance -------------------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_claimable_balance.LedgerKeyClaimableBalance - -LedgerKeyConfigSetting ----------------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_config_setting.LedgerKeyConfigSetting - -LedgerKeyContractCode ---------------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_contract_code.LedgerKeyContractCode - -LedgerKeyContractData ---------------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_contract_data.LedgerKeyContractData - -LedgerKeyData -------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_data.LedgerKeyData - -LedgerKeyLiquidityPool ----------------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_liquidity_pool.LedgerKeyLiquidityPool - -LedgerKeyOffer --------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_offer.LedgerKeyOffer - -LedgerKeyTrustLine ------------------- -.. autoclass:: stellar_sdk.xdr.ledger_key_trust_line.LedgerKeyTrustLine - -LedgerSCPMessages ------------------ -.. autoclass:: stellar_sdk.xdr.ledger_scp_messages.LedgerSCPMessages - -LedgerUpgrade -------------- -.. autoclass:: stellar_sdk.xdr.ledger_upgrade.LedgerUpgrade - -LedgerUpgradeType ------------------ -.. autoclass:: stellar_sdk.xdr.ledger_upgrade_type.LedgerUpgradeType - -Liabilities ------------ -.. autoclass:: stellar_sdk.xdr.liabilities.Liabilities - -LiquidityPoolConstantProductParameters --------------------------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_constant_product_parameters.LiquidityPoolConstantProductParameters - -LiquidityPoolDepositOp ----------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_deposit_op.LiquidityPoolDepositOp - -LiquidityPoolDepositResult --------------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_deposit_result.LiquidityPoolDepositResult - -LiquidityPoolDepositResultCode ------------------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_deposit_result_code.LiquidityPoolDepositResultCode - -LiquidityPoolEntry ------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_entry.LiquidityPoolEntry - -LiquidityPoolEntryBody ----------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_entry_body.LiquidityPoolEntryBody - -LiquidityPoolEntryConstantProduct ---------------------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_entry_constant_product.LiquidityPoolEntryConstantProduct - -LiquidityPoolParameters ------------------------ -.. autoclass:: stellar_sdk.xdr.liquidity_pool_parameters.LiquidityPoolParameters - -LiquidityPoolType ------------------ -.. autoclass:: stellar_sdk.xdr.liquidity_pool_type.LiquidityPoolType - -LiquidityPoolWithdrawOp ------------------------ -.. autoclass:: stellar_sdk.xdr.liquidity_pool_withdraw_op.LiquidityPoolWithdrawOp - -LiquidityPoolWithdrawResult ---------------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_withdraw_result.LiquidityPoolWithdrawResult - -LiquidityPoolWithdrawResultCode -------------------------------- -.. autoclass:: stellar_sdk.xdr.liquidity_pool_withdraw_result_code.LiquidityPoolWithdrawResultCode - -ManageBuyOfferOp ----------------- -.. autoclass:: stellar_sdk.xdr.manage_buy_offer_op.ManageBuyOfferOp - -ManageBuyOfferResult --------------------- -.. autoclass:: stellar_sdk.xdr.manage_buy_offer_result.ManageBuyOfferResult - -ManageBuyOfferResultCode ------------------------- -.. autoclass:: stellar_sdk.xdr.manage_buy_offer_result_code.ManageBuyOfferResultCode - -ManageDataOp ------------- -.. autoclass:: stellar_sdk.xdr.manage_data_op.ManageDataOp - -ManageDataResult ----------------- -.. autoclass:: stellar_sdk.xdr.manage_data_result.ManageDataResult - -ManageDataResultCode --------------------- -.. autoclass:: stellar_sdk.xdr.manage_data_result_code.ManageDataResultCode - -ManageOfferEffect ------------------ -.. autoclass:: stellar_sdk.xdr.manage_offer_effect.ManageOfferEffect - -ManageOfferSuccessResult ------------------------- -.. autoclass:: stellar_sdk.xdr.manage_offer_success_result.ManageOfferSuccessResult - -ManageOfferSuccessResultOffer ------------------------------ -.. autoclass:: stellar_sdk.xdr.manage_offer_success_result_offer.ManageOfferSuccessResultOffer - -ManageSellOfferOp ------------------ -.. autoclass:: stellar_sdk.xdr.manage_sell_offer_op.ManageSellOfferOp - -ManageSellOfferResult ---------------------- -.. autoclass:: stellar_sdk.xdr.manage_sell_offer_result.ManageSellOfferResult - -ManageSellOfferResultCode -------------------------- -.. autoclass:: stellar_sdk.xdr.manage_sell_offer_result_code.ManageSellOfferResultCode - -Memo ----- -.. autoclass:: stellar_sdk.xdr.memo.Memo - -MemoType --------- -.. autoclass:: stellar_sdk.xdr.memo_type.MemoType - -MessageType ------------ -.. autoclass:: stellar_sdk.xdr.message_type.MessageType - -MuxedAccount ------------- -.. autoclass:: stellar_sdk.xdr.muxed_account.MuxedAccount - -MuxedAccountMed25519 --------------------- -.. autoclass:: stellar_sdk.xdr.muxed_account_med25519.MuxedAccountMed25519 - -NodeID ------- -.. autoclass:: stellar_sdk.xdr.node_id.NodeID - -OfferEntry ----------- -.. autoclass:: stellar_sdk.xdr.offer_entry.OfferEntry - -OfferEntryExt -------------- -.. autoclass:: stellar_sdk.xdr.offer_entry_ext.OfferEntryExt - -OfferEntryFlags ---------------- -.. autoclass:: stellar_sdk.xdr.offer_entry_flags.OfferEntryFlags - -Opaque ------- -.. autoclass:: stellar_sdk.xdr.base.Opaque - -Operation ---------- -.. autoclass:: stellar_sdk.xdr.operation.Operation - -OperationBody -------------- -.. autoclass:: stellar_sdk.xdr.operation_body.OperationBody - -OperationMeta -------------- -.. autoclass:: stellar_sdk.xdr.operation_meta.OperationMeta - -OperationResult ---------------- -.. autoclass:: stellar_sdk.xdr.operation_result.OperationResult - -OperationResultCode -------------------- -.. autoclass:: stellar_sdk.xdr.operation_result_code.OperationResultCode - -OperationResultTr ------------------ -.. autoclass:: stellar_sdk.xdr.operation_result_tr.OperationResultTr - -OperationType -------------- -.. autoclass:: stellar_sdk.xdr.operation_type.OperationType - -PathPaymentStrictReceiveOp --------------------------- -.. autoclass:: stellar_sdk.xdr.path_payment_strict_receive_op.PathPaymentStrictReceiveOp - -PathPaymentStrictReceiveResult ------------------------------- -.. autoclass:: stellar_sdk.xdr.path_payment_strict_receive_result.PathPaymentStrictReceiveResult - -PathPaymentStrictReceiveResultCode ----------------------------------- -.. autoclass:: stellar_sdk.xdr.path_payment_strict_receive_result_code.PathPaymentStrictReceiveResultCode - -PathPaymentStrictReceiveResultSuccess -------------------------------------- -.. autoclass:: stellar_sdk.xdr.path_payment_strict_receive_result_success.PathPaymentStrictReceiveResultSuccess - -PathPaymentStrictSendOp ------------------------ -.. autoclass:: stellar_sdk.xdr.path_payment_strict_send_op.PathPaymentStrictSendOp - -PathPaymentStrictSendResult ---------------------------- -.. autoclass:: stellar_sdk.xdr.path_payment_strict_send_result.PathPaymentStrictSendResult - -PathPaymentStrictSendResultCode -------------------------------- -.. autoclass:: stellar_sdk.xdr.path_payment_strict_send_result_code.PathPaymentStrictSendResultCode - -PathPaymentStrictSendResultSuccess ----------------------------------- -.. autoclass:: stellar_sdk.xdr.path_payment_strict_send_result_success.PathPaymentStrictSendResultSuccess - -PaymentOp ---------- -.. autoclass:: stellar_sdk.xdr.payment_op.PaymentOp - -PaymentResult -------------- -.. autoclass:: stellar_sdk.xdr.payment_result.PaymentResult - -PaymentResultCode ------------------ -.. autoclass:: stellar_sdk.xdr.payment_result_code.PaymentResultCode - -PeerAddress ------------ -.. autoclass:: stellar_sdk.xdr.peer_address.PeerAddress - -PeerAddressIp -------------- -.. autoclass:: stellar_sdk.xdr.peer_address_ip.PeerAddressIp - -PeerStatList ------------- -.. autoclass:: stellar_sdk.xdr.peer_stat_list.PeerStatList - -PeerStats ---------- -.. autoclass:: stellar_sdk.xdr.peer_stats.PeerStats - -PersistedSCPState ------------------ -.. autoclass:: stellar_sdk.xdr.persisted_scp_state.PersistedSCPState - -PersistedSCPStateV0 -------------------- -.. autoclass:: stellar_sdk.xdr.persisted_scp_state_v0.PersistedSCPStateV0 - -PersistedSCPStateV1 -------------------- -.. autoclass:: stellar_sdk.xdr.persisted_scp_state_v1.PersistedSCPStateV1 - -PoolID ------- -.. autoclass:: stellar_sdk.xdr.pool_id.PoolID - -PreconditionType ----------------- -.. autoclass:: stellar_sdk.xdr.precondition_type.PreconditionType - -Preconditions -------------- -.. autoclass:: stellar_sdk.xdr.preconditions.Preconditions - -PreconditionsV2 ---------------- -.. autoclass:: stellar_sdk.xdr.preconditions_v2.PreconditionsV2 - -Price ------ -.. autoclass:: stellar_sdk.xdr.price.Price - -PublicKey ---------- -.. autoclass:: stellar_sdk.xdr.public_key.PublicKey - -PublicKeyType -------------- -.. autoclass:: stellar_sdk.xdr.public_key_type.PublicKeyType - -RestoreFootprintOp ------------------- -.. autoclass:: stellar_sdk.xdr.restore_footprint_op.RestoreFootprintOp - -RestoreFootprintResult ----------------------- -.. autoclass:: stellar_sdk.xdr.restore_footprint_result.RestoreFootprintResult - -RestoreFootprintResultCode --------------------------- -.. autoclass:: stellar_sdk.xdr.restore_footprint_result_code.RestoreFootprintResultCode - -RevokeSponsorshipOp -------------------- -.. autoclass:: stellar_sdk.xdr.revoke_sponsorship_op.RevokeSponsorshipOp - -RevokeSponsorshipOpSigner -------------------------- -.. autoclass:: stellar_sdk.xdr.revoke_sponsorship_op_signer.RevokeSponsorshipOpSigner - -RevokeSponsorshipResult ------------------------ -.. autoclass:: stellar_sdk.xdr.revoke_sponsorship_result.RevokeSponsorshipResult - -RevokeSponsorshipResultCode ---------------------------- -.. autoclass:: stellar_sdk.xdr.revoke_sponsorship_result_code.RevokeSponsorshipResultCode - -RevokeSponsorshipType ---------------------- -.. autoclass:: stellar_sdk.xdr.revoke_sponsorship_type.RevokeSponsorshipType - -SCAddress ---------- -.. autoclass:: stellar_sdk.xdr.sc_address.SCAddress - -SCAddressType -------------- -.. autoclass:: stellar_sdk.xdr.sc_address_type.SCAddressType - -SCBytes -------- -.. autoclass:: stellar_sdk.xdr.sc_bytes.SCBytes - -SCContractInstance ------------------- -.. autoclass:: stellar_sdk.xdr.sc_contract_instance.SCContractInstance - -SCEnvMetaEntry --------------- -.. autoclass:: stellar_sdk.xdr.sc_env_meta_entry.SCEnvMetaEntry - -SCEnvMetaKind -------------- -.. autoclass:: stellar_sdk.xdr.sc_env_meta_kind.SCEnvMetaKind - -SCError -------- -.. autoclass:: stellar_sdk.xdr.sc_error.SCError - -SCErrorCode ------------ -.. autoclass:: stellar_sdk.xdr.sc_error_code.SCErrorCode - -SCErrorType ------------ -.. autoclass:: stellar_sdk.xdr.sc_error_type.SCErrorType - -SCMap ------ -.. autoclass:: stellar_sdk.xdr.sc_map.SCMap - -SCMapEntry ----------- -.. autoclass:: stellar_sdk.xdr.sc_map_entry.SCMapEntry - -SCMetaEntry ------------ -.. autoclass:: stellar_sdk.xdr.sc_meta_entry.SCMetaEntry - -SCMetaKind ----------- -.. autoclass:: stellar_sdk.xdr.sc_meta_kind.SCMetaKind - -SCMetaV0 --------- -.. autoclass:: stellar_sdk.xdr.sc_meta_v0.SCMetaV0 - -SCNonceKey ----------- -.. autoclass:: stellar_sdk.xdr.sc_nonce_key.SCNonceKey - -SCPBallot ---------- -.. autoclass:: stellar_sdk.xdr.scp_ballot.SCPBallot - -SCPEnvelope ------------ -.. autoclass:: stellar_sdk.xdr.scp_envelope.SCPEnvelope - -SCPHistoryEntry ---------------- -.. autoclass:: stellar_sdk.xdr.scp_history_entry.SCPHistoryEntry - -SCPHistoryEntryV0 ------------------ -.. autoclass:: stellar_sdk.xdr.scp_history_entry_v0.SCPHistoryEntryV0 - -SCPNomination -------------- -.. autoclass:: stellar_sdk.xdr.scp_nomination.SCPNomination - -SCPQuorumSet ------------- -.. autoclass:: stellar_sdk.xdr.scp_quorum_set.SCPQuorumSet - -SCPStatement ------------- -.. autoclass:: stellar_sdk.xdr.scp_statement.SCPStatement - -SCPStatementConfirm -------------------- -.. autoclass:: stellar_sdk.xdr.scp_statement_confirm.SCPStatementConfirm - -SCPStatementExternalize ------------------------ -.. autoclass:: stellar_sdk.xdr.scp_statement_externalize.SCPStatementExternalize - -SCPStatementPledges -------------------- -.. autoclass:: stellar_sdk.xdr.scp_statement_pledges.SCPStatementPledges - -SCPStatementPrepare -------------------- -.. autoclass:: stellar_sdk.xdr.scp_statement_prepare.SCPStatementPrepare - -SCPStatementType ----------------- -.. autoclass:: stellar_sdk.xdr.scp_statement_type.SCPStatementType - -SCSpecEntry ------------ -.. autoclass:: stellar_sdk.xdr.sc_spec_entry.SCSpecEntry - -SCSpecEntryKind ---------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_entry_kind.SCSpecEntryKind - -SCSpecFunctionInputV0 ---------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_function_input_v0.SCSpecFunctionInputV0 - -SCSpecFunctionV0 ----------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_function_v0.SCSpecFunctionV0 - -SCSpecType ----------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type.SCSpecType - -SCSpecTypeBytesN ----------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_bytes_n.SCSpecTypeBytesN - -SCSpecTypeDef -------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_def.SCSpecTypeDef - -SCSpecTypeMap -------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_map.SCSpecTypeMap - -SCSpecTypeOption ----------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_option.SCSpecTypeOption - -SCSpecTypeResult ----------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_result.SCSpecTypeResult - -SCSpecTypeSet -------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_set.SCSpecTypeSet - -SCSpecTypeTuple ---------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_tuple.SCSpecTypeTuple - -SCSpecTypeUDT -------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_udt.SCSpecTypeUDT - -SCSpecTypeVec -------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_type_vec.SCSpecTypeVec - -SCSpecUDTEnumCaseV0 -------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_enum_case_v0.SCSpecUDTEnumCaseV0 - -SCSpecUDTEnumV0 ---------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_enum_v0.SCSpecUDTEnumV0 - -SCSpecUDTErrorEnumCaseV0 ------------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_error_enum_case_v0.SCSpecUDTErrorEnumCaseV0 - -SCSpecUDTErrorEnumV0 --------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_error_enum_v0.SCSpecUDTErrorEnumV0 - -SCSpecUDTStructFieldV0 ----------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_struct_field_v0.SCSpecUDTStructFieldV0 - -SCSpecUDTStructV0 ------------------ -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_struct_v0.SCSpecUDTStructV0 - -SCSpecUDTUnionCaseTupleV0 -------------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_union_case_tuple_v0.SCSpecUDTUnionCaseTupleV0 - -SCSpecUDTUnionCaseV0 --------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_union_case_v0.SCSpecUDTUnionCaseV0 - -SCSpecUDTUnionCaseV0Kind ------------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_union_case_v0_kind.SCSpecUDTUnionCaseV0Kind - -SCSpecUDTUnionCaseVoidV0 ------------------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_union_case_void_v0.SCSpecUDTUnionCaseVoidV0 - -SCSpecUDTUnionV0 ----------------- -.. autoclass:: stellar_sdk.xdr.sc_spec_udt_union_v0.SCSpecUDTUnionV0 - -SCString --------- -.. autoclass:: stellar_sdk.xdr.sc_string.SCString - -SCSymbol --------- -.. autoclass:: stellar_sdk.xdr.sc_symbol.SCSymbol - -SCVal ------ -.. autoclass:: stellar_sdk.xdr.sc_val.SCVal - -SCValType ---------- -.. autoclass:: stellar_sdk.xdr.sc_val_type.SCValType - -SCVec ------ -.. autoclass:: stellar_sdk.xdr.sc_vec.SCVec - -SendMore --------- -.. autoclass:: stellar_sdk.xdr.send_more.SendMore - -SendMoreExtended ----------------- -.. autoclass:: stellar_sdk.xdr.send_more_extended.SendMoreExtended - -SequenceNumber --------------- -.. autoclass:: stellar_sdk.xdr.sequence_number.SequenceNumber - -SetOptionsOp ------------- -.. autoclass:: stellar_sdk.xdr.set_options_op.SetOptionsOp - -SetOptionsResult ----------------- -.. autoclass:: stellar_sdk.xdr.set_options_result.SetOptionsResult - -SetOptionsResultCode --------------------- -.. autoclass:: stellar_sdk.xdr.set_options_result_code.SetOptionsResultCode - -SetTrustLineFlagsOp -------------------- -.. autoclass:: stellar_sdk.xdr.set_trust_line_flags_op.SetTrustLineFlagsOp - -SetTrustLineFlagsResult ------------------------ -.. autoclass:: stellar_sdk.xdr.set_trust_line_flags_result.SetTrustLineFlagsResult - -SetTrustLineFlagsResultCode ---------------------------- -.. autoclass:: stellar_sdk.xdr.set_trust_line_flags_result_code.SetTrustLineFlagsResultCode - -Signature ---------- -.. autoclass:: stellar_sdk.xdr.signature.Signature - -SignatureHint -------------- -.. autoclass:: stellar_sdk.xdr.signature_hint.SignatureHint - -SignedSurveyRequestMessage --------------------------- -.. autoclass:: stellar_sdk.xdr.signed_survey_request_message.SignedSurveyRequestMessage - -SignedSurveyResponseMessage ---------------------------- -.. autoclass:: stellar_sdk.xdr.signed_survey_response_message.SignedSurveyResponseMessage - -Signer ------- -.. autoclass:: stellar_sdk.xdr.signer.Signer - -SignerKey ---------- -.. autoclass:: stellar_sdk.xdr.signer_key.SignerKey - -SignerKeyEd25519SignedPayload ------------------------------ -.. autoclass:: stellar_sdk.xdr.signer_key_ed25519_signed_payload.SignerKeyEd25519SignedPayload - -SignerKeyType -------------- -.. autoclass:: stellar_sdk.xdr.signer_key_type.SignerKeyType - -SimplePaymentResult -------------------- -.. autoclass:: stellar_sdk.xdr.simple_payment_result.SimplePaymentResult - -SorobanAddressCredentials -------------------------- -.. autoclass:: stellar_sdk.xdr.soroban_address_credentials.SorobanAddressCredentials - -SorobanAuthorizationEntry -------------------------- -.. autoclass:: stellar_sdk.xdr.soroban_authorization_entry.SorobanAuthorizationEntry - -SorobanAuthorizedContractFunction ---------------------------------- -.. autoclass:: stellar_sdk.xdr.soroban_authorized_contract_function.SorobanAuthorizedContractFunction - -SorobanAuthorizedFunction -------------------------- -.. autoclass:: stellar_sdk.xdr.soroban_authorized_function.SorobanAuthorizedFunction - -SorobanAuthorizedFunctionType ------------------------------ -.. autoclass:: stellar_sdk.xdr.soroban_authorized_function_type.SorobanAuthorizedFunctionType - -SorobanAuthorizedInvocation ---------------------------- -.. autoclass:: stellar_sdk.xdr.soroban_authorized_invocation.SorobanAuthorizedInvocation - -SorobanCredentials ------------------- -.. autoclass:: stellar_sdk.xdr.soroban_credentials.SorobanCredentials - -SorobanCredentialsType ----------------------- -.. autoclass:: stellar_sdk.xdr.soroban_credentials_type.SorobanCredentialsType - -SorobanResources ----------------- -.. autoclass:: stellar_sdk.xdr.soroban_resources.SorobanResources - -SorobanTransactionData ----------------------- -.. autoclass:: stellar_sdk.xdr.soroban_transaction_data.SorobanTransactionData - -SorobanTransactionMeta ----------------------- -.. autoclass:: stellar_sdk.xdr.soroban_transaction_meta.SorobanTransactionMeta - -SponsorshipDescriptor ---------------------- -.. autoclass:: stellar_sdk.xdr.sponsorship_descriptor.SponsorshipDescriptor - -StateExpirationSettings ------------------------ -.. autoclass:: stellar_sdk.xdr.state_expiration_settings.StateExpirationSettings - -StellarMessage --------------- -.. autoclass:: stellar_sdk.xdr.stellar_message.StellarMessage - -StellarValue ------------- -.. autoclass:: stellar_sdk.xdr.stellar_value.StellarValue - -StellarValueExt ---------------- -.. autoclass:: stellar_sdk.xdr.stellar_value_ext.StellarValueExt - -StellarValueType ----------------- -.. autoclass:: stellar_sdk.xdr.stellar_value_type.StellarValueType - -StoredTransactionSet --------------------- -.. autoclass:: stellar_sdk.xdr.stored_transaction_set.StoredTransactionSet - -String ------- -.. autoclass:: stellar_sdk.xdr.base.String - -String32 --------- -.. autoclass:: stellar_sdk.xdr.string32.String32 - -String64 --------- -.. autoclass:: stellar_sdk.xdr.string64.String64 - -SurveyMessageCommandType ------------------------- -.. autoclass:: stellar_sdk.xdr.survey_message_command_type.SurveyMessageCommandType - -SurveyMessageResponseType -------------------------- -.. autoclass:: stellar_sdk.xdr.survey_message_response_type.SurveyMessageResponseType - -SurveyRequestMessage --------------------- -.. autoclass:: stellar_sdk.xdr.survey_request_message.SurveyRequestMessage - -SurveyResponseBody ------------------- -.. autoclass:: stellar_sdk.xdr.survey_response_body.SurveyResponseBody - -SurveyResponseMessage ---------------------- -.. autoclass:: stellar_sdk.xdr.survey_response_message.SurveyResponseMessage - -ThresholdIndexes ----------------- -.. autoclass:: stellar_sdk.xdr.threshold_indexes.ThresholdIndexes - -Thresholds ----------- -.. autoclass:: stellar_sdk.xdr.thresholds.Thresholds - -TimeBounds ----------- -.. autoclass:: stellar_sdk.xdr.time_bounds.TimeBounds - -TimePoint ---------- -.. autoclass:: stellar_sdk.xdr.time_point.TimePoint - -TopologyResponseBodyV0 ----------------------- -.. autoclass:: stellar_sdk.xdr.topology_response_body_v0.TopologyResponseBodyV0 - -TopologyResponseBodyV1 ----------------------- -.. autoclass:: stellar_sdk.xdr.topology_response_body_v1.TopologyResponseBodyV1 - -Transaction ------------ -.. autoclass:: stellar_sdk.xdr.transaction.Transaction - -TransactionEnvelope -------------------- -.. autoclass:: stellar_sdk.xdr.transaction_envelope.TransactionEnvelope - -TransactionExt --------------- -.. autoclass:: stellar_sdk.xdr.transaction_ext.TransactionExt - -TransactionHistoryEntry ------------------------ -.. autoclass:: stellar_sdk.xdr.transaction_history_entry.TransactionHistoryEntry - -TransactionHistoryEntryExt --------------------------- -.. autoclass:: stellar_sdk.xdr.transaction_history_entry_ext.TransactionHistoryEntryExt - -TransactionHistoryResultEntry ------------------------------ -.. autoclass:: stellar_sdk.xdr.transaction_history_result_entry.TransactionHistoryResultEntry - -TransactionHistoryResultEntryExt --------------------------------- -.. autoclass:: stellar_sdk.xdr.transaction_history_result_entry_ext.TransactionHistoryResultEntryExt - -TransactionMeta ---------------- -.. autoclass:: stellar_sdk.xdr.transaction_meta.TransactionMeta - -TransactionMetaV1 ------------------ -.. autoclass:: stellar_sdk.xdr.transaction_meta_v1.TransactionMetaV1 - -TransactionMetaV2 ------------------ -.. autoclass:: stellar_sdk.xdr.transaction_meta_v2.TransactionMetaV2 - -TransactionMetaV3 ------------------ -.. autoclass:: stellar_sdk.xdr.transaction_meta_v3.TransactionMetaV3 - -TransactionPhase ----------------- -.. autoclass:: stellar_sdk.xdr.transaction_phase.TransactionPhase - -TransactionResult ------------------ -.. autoclass:: stellar_sdk.xdr.transaction_result.TransactionResult - -TransactionResultCode ---------------------- -.. autoclass:: stellar_sdk.xdr.transaction_result_code.TransactionResultCode - -TransactionResultExt --------------------- -.. autoclass:: stellar_sdk.xdr.transaction_result_ext.TransactionResultExt - -TransactionResultMeta ---------------------- -.. autoclass:: stellar_sdk.xdr.transaction_result_meta.TransactionResultMeta - -TransactionResultPair ---------------------- -.. autoclass:: stellar_sdk.xdr.transaction_result_pair.TransactionResultPair - -TransactionResultResult ------------------------ -.. autoclass:: stellar_sdk.xdr.transaction_result_result.TransactionResultResult - -TransactionResultSet --------------------- -.. autoclass:: stellar_sdk.xdr.transaction_result_set.TransactionResultSet - -TransactionSet --------------- -.. autoclass:: stellar_sdk.xdr.transaction_set.TransactionSet - -TransactionSetV1 ----------------- -.. autoclass:: stellar_sdk.xdr.transaction_set_v1.TransactionSetV1 - -TransactionSignaturePayload ---------------------------- -.. autoclass:: stellar_sdk.xdr.transaction_signature_payload.TransactionSignaturePayload - -TransactionSignaturePayloadTaggedTransaction --------------------------------------------- -.. autoclass:: stellar_sdk.xdr.transaction_signature_payload_tagged_transaction.TransactionSignaturePayloadTaggedTransaction - -TransactionV0 -------------- -.. autoclass:: stellar_sdk.xdr.transaction_v0.TransactionV0 - -TransactionV0Envelope ---------------------- -.. autoclass:: stellar_sdk.xdr.transaction_v0_envelope.TransactionV0Envelope - -TransactionV0Ext ----------------- -.. autoclass:: stellar_sdk.xdr.transaction_v0_ext.TransactionV0Ext - -TransactionV1Envelope ---------------------- -.. autoclass:: stellar_sdk.xdr.transaction_v1_envelope.TransactionV1Envelope - -TrustLineAsset --------------- -.. autoclass:: stellar_sdk.xdr.trust_line_asset.TrustLineAsset - -TrustLineEntry --------------- -.. autoclass:: stellar_sdk.xdr.trust_line_entry.TrustLineEntry - -TrustLineEntryExt ------------------ -.. autoclass:: stellar_sdk.xdr.trust_line_entry_ext.TrustLineEntryExt - -TrustLineEntryExtensionV2 -------------------------- -.. autoclass:: stellar_sdk.xdr.trust_line_entry_extension_v2.TrustLineEntryExtensionV2 - -TrustLineEntryExtensionV2Ext ----------------------------- -.. autoclass:: stellar_sdk.xdr.trust_line_entry_extension_v2_ext.TrustLineEntryExtensionV2Ext - -TrustLineEntryV1 ----------------- -.. autoclass:: stellar_sdk.xdr.trust_line_entry_v1.TrustLineEntryV1 - -TrustLineEntryV1Ext -------------------- -.. autoclass:: stellar_sdk.xdr.trust_line_entry_v1_ext.TrustLineEntryV1Ext - -TrustLineFlags --------------- -.. autoclass:: stellar_sdk.xdr.trust_line_flags.TrustLineFlags - -TxAdvertVector --------------- -.. autoclass:: stellar_sdk.xdr.tx_advert_vector.TxAdvertVector - -TxDemandVector --------------- -.. autoclass:: stellar_sdk.xdr.tx_demand_vector.TxDemandVector - -TxSetComponent --------------- -.. autoclass:: stellar_sdk.xdr.tx_set_component.TxSetComponent - -TxSetComponentTxsMaybeDiscountedFee ------------------------------------ -.. autoclass:: stellar_sdk.xdr.tx_set_component_txs_maybe_discounted_fee.TxSetComponentTxsMaybeDiscountedFee - -TxSetComponentType ------------------- -.. autoclass:: stellar_sdk.xdr.tx_set_component_type.TxSetComponentType - -UInt128Parts ------------- -.. autoclass:: stellar_sdk.xdr.u_int128_parts.UInt128Parts - -UInt256Parts ------------- -.. autoclass:: stellar_sdk.xdr.u_int256_parts.UInt256Parts - -Uint256 -------- -.. autoclass:: stellar_sdk.xdr.uint256.Uint256 - -Uint32 ------- -.. autoclass:: stellar_sdk.xdr.uint32.Uint32 - -Uint64 ------- -.. autoclass:: stellar_sdk.xdr.uint64.Uint64 - -UnsignedHyper -------------- -.. autoclass:: stellar_sdk.xdr.base.UnsignedHyper - -UnsignedInteger ---------------- -.. autoclass:: stellar_sdk.xdr.base.UnsignedInteger - -UpgradeEntryMeta ----------------- -.. autoclass:: stellar_sdk.xdr.upgrade_entry_meta.UpgradeEntryMeta - -UpgradeType ------------ -.. autoclass:: stellar_sdk.xdr.upgrade_type.UpgradeType - -Value ------ -.. autoclass:: stellar_sdk.xdr.value.Value - -Constants ---------- -.. autodata:: stellar_sdk.xdr.constants.AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED -.. autodata:: stellar_sdk.xdr.constants.CONTRACT_COST_COUNT_LIMIT -.. autodata:: stellar_sdk.xdr.constants.LIQUIDITY_POOL_FEE_V18 -.. autodata:: stellar_sdk.xdr.constants.MASK_ACCOUNT_FLAGS -.. autodata:: stellar_sdk.xdr.constants.MASK_ACCOUNT_FLAGS_V17 -.. autodata:: stellar_sdk.xdr.constants.MASK_CLAIMABLE_BALANCE_FLAGS -.. autodata:: stellar_sdk.xdr.constants.MASK_CONTRACT_DATA_FLAGS_V20 -.. autodata:: stellar_sdk.xdr.constants.MASK_LEDGER_HEADER_FLAGS -.. autodata:: stellar_sdk.xdr.constants.MASK_OFFERENTRY_FLAGS -.. autodata:: stellar_sdk.xdr.constants.MASK_TRUSTLINE_FLAGS -.. autodata:: stellar_sdk.xdr.constants.MASK_TRUSTLINE_FLAGS_V13 -.. autodata:: stellar_sdk.xdr.constants.MASK_TRUSTLINE_FLAGS_V17 -.. autodata:: stellar_sdk.xdr.constants.MAX_OPS_PER_TX -.. autodata:: stellar_sdk.xdr.constants.MAX_SIGNERS -.. autodata:: stellar_sdk.xdr.constants.SCSYMBOL_LIMIT -.. autodata:: stellar_sdk.xdr.constants.SC_SPEC_DOC_LIMIT -.. autodata:: stellar_sdk.xdr.constants.TX_ADVERT_VECTOR_MAX_SIZE -.. autodata:: stellar_sdk.xdr.constants.TX_DEMAND_VECTOR_MAX_SIZE diff --git a/stellar_sdk/transaction_builder.py b/stellar_sdk/transaction_builder.py index 07e1d4b4..3cec3025 100644 --- a/stellar_sdk/transaction_builder.py +++ b/stellar_sdk/transaction_builder.py @@ -1249,18 +1249,24 @@ def append_invoke_contract_function_op( if not StrKey.is_valid_contract(contract_id): raise ValueError("`contract_id` is invalid.") - invoke_params = [ + invoke_params = stellar_xdr.InvokeContractArgs( + contract_address=Address(contract_id).to_xdr_sc_address(), + function_name=stellar_xdr.SCSymbol(sc_symbol=function_name.encode("utf-8")), + args=list(parameters), + ) + + """ invoke_params = [ Address(contract_id).to_xdr_sc_val(), stellar_xdr.SCVal( stellar_xdr.SCValType.SCV_SYMBOL, sym=stellar_xdr.SCSymbol(sc_symbol=function_name.encode("utf-8")), ), *parameters, - ] + ] """ host_function = stellar_xdr.HostFunction( stellar_xdr.HostFunctionType.HOST_FUNCTION_TYPE_INVOKE_CONTRACT, - invoke_contract=stellar_xdr.SCVec(invoke_params), + invoke_contract=invoke_params, ) op = InvokeHostFunction(host_function=host_function, auth=auth, source=source) return self.append_operation(op) diff --git a/stellar_sdk/xdr/__init__.py b/stellar_sdk/xdr/__init__.py index c3015fd6..25e23e84 100644 --- a/stellar_sdk/xdr/__init__.py +++ b/stellar_sdk/xdr/__init__.py @@ -1,440 +1,422 @@ # Automatically generated by xdrgen # DO NOT EDIT or your changes may be overwritten -from .account_entry import AccountEntry -from .account_entry_ext import AccountEntryExt -from .account_entry_extension_v1 import AccountEntryExtensionV1 -from .account_entry_extension_v1_ext import AccountEntryExtensionV1Ext -from .account_entry_extension_v2 import AccountEntryExtensionV2 -from .account_entry_extension_v2_ext import AccountEntryExtensionV2Ext -from .account_entry_extension_v3 import AccountEntryExtensionV3 -from .account_flags import AccountFlags -from .account_id import AccountID -from .account_merge_result import AccountMergeResult -from .account_merge_result_code import AccountMergeResultCode -from .allow_trust_op import AllowTrustOp -from .allow_trust_result import AllowTrustResult -from .allow_trust_result_code import AllowTrustResultCode -from .alpha_num4 import AlphaNum4 -from .alpha_num12 import AlphaNum12 -from .asset import Asset -from .asset_code import AssetCode +from .base import * +from .constants import * +from .value import Value +from .scp_ballot import SCPBallot +from .scp_statement_type import SCPStatementType +from .scp_nomination import SCPNomination +from .scp_statement_prepare import SCPStatementPrepare +from .scp_statement_confirm import SCPStatementConfirm +from .scp_statement_externalize import SCPStatementExternalize +from .scp_statement_pledges import SCPStatementPledges +from .scp_statement import SCPStatement +from .scp_envelope import SCPEnvelope +from .scp_quorum_set import SCPQuorumSet +from .thresholds import Thresholds +from .string32 import String32 +from .string64 import String64 +from .sequence_number import SequenceNumber +from .data_value import DataValue +from .pool_id import PoolID from .asset_code4 import AssetCode4 from .asset_code12 import AssetCode12 from .asset_type import AssetType -from .auth import Auth -from .auth_cert import AuthCert -from .authenticated_message import AuthenticatedMessage -from .authenticated_message_v0 import AuthenticatedMessageV0 -from .base import * -from .begin_sponsoring_future_reserves_op import BeginSponsoringFutureReservesOp -from .begin_sponsoring_future_reserves_result import BeginSponsoringFutureReservesResult -from .begin_sponsoring_future_reserves_result_code import ( - BeginSponsoringFutureReservesResultCode, -) -from .bucket_entry import BucketEntry -from .bucket_entry_type import BucketEntryType -from .bucket_metadata import BucketMetadata -from .bucket_metadata_ext import BucketMetadataExt -from .bump_footprint_expiration_op import BumpFootprintExpirationOp -from .bump_footprint_expiration_result import BumpFootprintExpirationResult -from .bump_footprint_expiration_result_code import BumpFootprintExpirationResultCode -from .bump_sequence_op import BumpSequenceOp -from .bump_sequence_result import BumpSequenceResult -from .bump_sequence_result_code import BumpSequenceResultCode -from .change_trust_asset import ChangeTrustAsset -from .change_trust_op import ChangeTrustOp -from .change_trust_result import ChangeTrustResult -from .change_trust_result_code import ChangeTrustResultCode -from .claim_atom import ClaimAtom -from .claim_atom_type import ClaimAtomType -from .claim_claimable_balance_op import ClaimClaimableBalanceOp -from .claim_claimable_balance_result import ClaimClaimableBalanceResult -from .claim_claimable_balance_result_code import ClaimClaimableBalanceResultCode -from .claim_liquidity_atom import ClaimLiquidityAtom -from .claim_offer_atom import ClaimOfferAtom -from .claim_offer_atom_v0 import ClaimOfferAtomV0 -from .claim_predicate import ClaimPredicate +from .asset_code import AssetCode +from .alpha_num4 import AlphaNum4 +from .alpha_num12 import AlphaNum12 +from .asset import Asset +from .price import Price +from .liabilities import Liabilities +from .threshold_indexes import ThresholdIndexes +from .ledger_entry_type import LedgerEntryType +from .signer import Signer +from .account_flags import AccountFlags +from .sponsorship_descriptor import SponsorshipDescriptor +from .account_entry_extension_v3 import AccountEntryExtensionV3 +from .account_entry_extension_v2_ext import AccountEntryExtensionV2Ext +from .account_entry_extension_v2 import AccountEntryExtensionV2 +from .account_entry_extension_v1_ext import AccountEntryExtensionV1Ext +from .account_entry_extension_v1 import AccountEntryExtensionV1 +from .account_entry_ext import AccountEntryExt +from .account_entry import AccountEntry +from .trust_line_flags import TrustLineFlags +from .liquidity_pool_type import LiquidityPoolType +from .trust_line_asset import TrustLineAsset +from .trust_line_entry_extension_v2_ext import TrustLineEntryExtensionV2Ext +from .trust_line_entry_extension_v2 import TrustLineEntryExtensionV2 +from .trust_line_entry_v1_ext import TrustLineEntryV1Ext +from .trust_line_entry_v1 import TrustLineEntryV1 +from .trust_line_entry_ext import TrustLineEntryExt +from .trust_line_entry import TrustLineEntry +from .offer_entry_flags import OfferEntryFlags +from .offer_entry_ext import OfferEntryExt +from .offer_entry import OfferEntry +from .data_entry_ext import DataEntryExt +from .data_entry import DataEntry from .claim_predicate_type import ClaimPredicateType -from .claimable_balance_entry import ClaimableBalanceEntry -from .claimable_balance_entry_ext import ClaimableBalanceEntryExt -from .claimable_balance_entry_extension_v1 import ClaimableBalanceEntryExtensionV1 -from .claimable_balance_entry_extension_v1_ext import ( - ClaimableBalanceEntryExtensionV1Ext, -) -from .claimable_balance_flags import ClaimableBalanceFlags -from .claimable_balance_id import ClaimableBalanceID -from .claimable_balance_id_type import ClaimableBalanceIDType -from .claimant import Claimant +from .claim_predicate import ClaimPredicate from .claimant_type import ClaimantType from .claimant_v0 import ClaimantV0 -from .clawback_claimable_balance_op import ClawbackClaimableBalanceOp -from .clawback_claimable_balance_result import ClawbackClaimableBalanceResult -from .clawback_claimable_balance_result_code import ClawbackClaimableBalanceResultCode -from .clawback_op import ClawbackOp -from .clawback_result import ClawbackResult -from .clawback_result_code import ClawbackResultCode -from .config_setting_contract_bandwidth_v0 import ConfigSettingContractBandwidthV0 -from .config_setting_contract_compute_v0 import ConfigSettingContractComputeV0 -from .config_setting_contract_events_v0 import ConfigSettingContractEventsV0 -from .config_setting_contract_execution_lanes_v0 import ( - ConfigSettingContractExecutionLanesV0, -) -from .config_setting_contract_historical_data_v0 import ( - ConfigSettingContractHistoricalDataV0, -) -from .config_setting_contract_ledger_cost_v0 import ConfigSettingContractLedgerCostV0 -from .config_setting_entry import ConfigSettingEntry -from .config_setting_id import ConfigSettingID -from .config_upgrade_set import ConfigUpgradeSet -from .config_upgrade_set_key import ConfigUpgradeSetKey -from .constants import * -from .contract_code_entry import ContractCodeEntry -from .contract_cost_param_entry import ContractCostParamEntry -from .contract_cost_params import ContractCostParams -from .contract_cost_type import ContractCostType +from .claimant import Claimant +from .claimable_balance_id_type import ClaimableBalanceIDType +from .claimable_balance_id import ClaimableBalanceID +from .claimable_balance_flags import ClaimableBalanceFlags +from .claimable_balance_entry_extension_v1_ext import ClaimableBalanceEntryExtensionV1Ext +from .claimable_balance_entry_extension_v1 import ClaimableBalanceEntryExtensionV1 +from .claimable_balance_entry_ext import ClaimableBalanceEntryExt +from .claimable_balance_entry import ClaimableBalanceEntry +from .liquidity_pool_constant_product_parameters import LiquidityPoolConstantProductParameters +from .liquidity_pool_entry_constant_product import LiquidityPoolEntryConstantProduct +from .liquidity_pool_entry_body import LiquidityPoolEntryBody +from .liquidity_pool_entry import LiquidityPoolEntry from .contract_data_durability import ContractDataDurability from .contract_data_entry import ContractDataEntry -from .contract_event import ContractEvent -from .contract_event_body import ContractEventBody +from .contract_code_entry import ContractCodeEntry +from .expiration_entry import ExpirationEntry +from .ledger_entry_extension_v1_ext import LedgerEntryExtensionV1Ext +from .ledger_entry_extension_v1 import LedgerEntryExtensionV1 +from .ledger_entry_data import LedgerEntryData +from .ledger_entry_ext import LedgerEntryExt +from .ledger_entry import LedgerEntry +from .ledger_key_account import LedgerKeyAccount +from .ledger_key_trust_line import LedgerKeyTrustLine +from .ledger_key_offer import LedgerKeyOffer +from .ledger_key_data import LedgerKeyData +from .ledger_key_claimable_balance import LedgerKeyClaimableBalance +from .ledger_key_liquidity_pool import LedgerKeyLiquidityPool +from .ledger_key_contract_data import LedgerKeyContractData +from .ledger_key_contract_code import LedgerKeyContractCode +from .ledger_key_config_setting import LedgerKeyConfigSetting +from .ledger_key_expiration import LedgerKeyExpiration +from .ledger_key import LedgerKey +from .envelope_type import EnvelopeType +from .upgrade_type import UpgradeType +from .stellar_value_type import StellarValueType +from .ledger_close_value_signature import LedgerCloseValueSignature +from .stellar_value_ext import StellarValueExt +from .stellar_value import StellarValue +from .ledger_header_flags import LedgerHeaderFlags +from .ledger_header_extension_v1_ext import LedgerHeaderExtensionV1Ext +from .ledger_header_extension_v1 import LedgerHeaderExtensionV1 +from .ledger_header_ext import LedgerHeaderExt +from .ledger_header import LedgerHeader +from .ledger_upgrade_type import LedgerUpgradeType +from .config_upgrade_set_key import ConfigUpgradeSetKey +from .ledger_upgrade import LedgerUpgrade +from .config_upgrade_set import ConfigUpgradeSet +from .bucket_entry_type import BucketEntryType +from .bucket_metadata_ext import BucketMetadataExt +from .bucket_metadata import BucketMetadata +from .bucket_entry import BucketEntry +from .tx_set_component_type import TxSetComponentType +from .tx_set_component_txs_maybe_discounted_fee import TxSetComponentTxsMaybeDiscountedFee +from .tx_set_component import TxSetComponent +from .transaction_phase import TransactionPhase +from .transaction_set import TransactionSet +from .transaction_set_v1 import TransactionSetV1 +from .generalized_transaction_set import GeneralizedTransactionSet +from .transaction_result_pair import TransactionResultPair +from .transaction_result_set import TransactionResultSet +from .transaction_history_entry_ext import TransactionHistoryEntryExt +from .transaction_history_entry import TransactionHistoryEntry +from .transaction_history_result_entry_ext import TransactionHistoryResultEntryExt +from .transaction_history_result_entry import TransactionHistoryResultEntry +from .ledger_header_history_entry_ext import LedgerHeaderHistoryEntryExt +from .ledger_header_history_entry import LedgerHeaderHistoryEntry +from .ledger_scp_messages import LedgerSCPMessages +from .scp_history_entry_v0 import SCPHistoryEntryV0 +from .scp_history_entry import SCPHistoryEntry +from .ledger_entry_change_type import LedgerEntryChangeType +from .ledger_entry_change import LedgerEntryChange +from .ledger_entry_changes import LedgerEntryChanges +from .operation_meta import OperationMeta +from .transaction_meta_v1 import TransactionMetaV1 +from .transaction_meta_v2 import TransactionMetaV2 from .contract_event_type import ContractEventType from .contract_event_v0 import ContractEventV0 -from .contract_executable import ContractExecutable -from .contract_executable_type import ContractExecutableType -from .contract_id_preimage import ContractIDPreimage -from .contract_id_preimage_from_address import ContractIDPreimageFromAddress -from .contract_id_preimage_type import ContractIDPreimageType -from .create_account_op import CreateAccountOp -from .create_account_result import CreateAccountResult -from .create_account_result_code import CreateAccountResultCode -from .create_claimable_balance_op import CreateClaimableBalanceOp -from .create_claimable_balance_result import CreateClaimableBalanceResult -from .create_claimable_balance_result_code import CreateClaimableBalanceResultCode -from .create_contract_args import CreateContractArgs -from .create_passive_sell_offer_op import CreatePassiveSellOfferOp -from .crypto_key_type import CryptoKeyType -from .curve25519_public import Curve25519Public -from .curve25519_secret import Curve25519Secret -from .data_entry import DataEntry -from .data_entry_ext import DataEntryExt -from .data_value import DataValue -from .decorated_signature import DecoratedSignature +from .contract_event_body import ContractEventBody +from .contract_event import ContractEvent from .diagnostic_event import DiagnosticEvent +from .soroban_transaction_meta import SorobanTransactionMeta +from .transaction_meta_v3 import TransactionMetaV3 +from .invoke_host_function_success_pre_image import InvokeHostFunctionSuccessPreImage +from .transaction_meta import TransactionMeta +from .transaction_result_meta import TransactionResultMeta +from .upgrade_entry_meta import UpgradeEntryMeta +from .ledger_close_meta_v0 import LedgerCloseMetaV0 +from .ledger_close_meta_v1 import LedgerCloseMetaV1 +from .ledger_close_meta_v2 import LedgerCloseMetaV2 +from .ledger_close_meta import LedgerCloseMeta +from .error_code import ErrorCode +from .error import Error +from .send_more import SendMore +from .send_more_extended import SendMoreExtended +from .auth_cert import AuthCert +from .hello import Hello +from .auth import Auth +from .ip_addr_type import IPAddrType +from .peer_address_ip import PeerAddressIp +from .peer_address import PeerAddress +from .message_type import MessageType from .dont_have import DontHave -from .duration import Duration +from .survey_message_command_type import SurveyMessageCommandType +from .survey_message_response_type import SurveyMessageResponseType +from .survey_request_message import SurveyRequestMessage +from .signed_survey_request_message import SignedSurveyRequestMessage from .encrypted_body import EncryptedBody -from .end_sponsoring_future_reserves_result import EndSponsoringFutureReservesResult -from .end_sponsoring_future_reserves_result_code import ( - EndSponsoringFutureReservesResultCode, -) -from .envelope_type import EnvelopeType -from .error import Error -from .error_code import ErrorCode -from .eviction_iterator import EvictionIterator -from .expiration_entry import ExpirationEntry -from .extension_point import ExtensionPoint -from .fee_bump_transaction import FeeBumpTransaction -from .fee_bump_transaction_envelope import FeeBumpTransactionEnvelope -from .fee_bump_transaction_ext import FeeBumpTransactionExt -from .fee_bump_transaction_inner_tx import FeeBumpTransactionInnerTx +from .survey_response_message import SurveyResponseMessage +from .signed_survey_response_message import SignedSurveyResponseMessage +from .peer_stats import PeerStats +from .peer_stat_list import PeerStatList +from .topology_response_body_v0 import TopologyResponseBodyV0 +from .topology_response_body_v1 import TopologyResponseBodyV1 +from .survey_response_body import SurveyResponseBody +from .tx_advert_vector import TxAdvertVector from .flood_advert import FloodAdvert +from .tx_demand_vector import TxDemandVector from .flood_demand import FloodDemand -from .generalized_transaction_set import GeneralizedTransactionSet -from .hash import Hash -from .hash_id_preimage import HashIDPreimage -from .hash_id_preimage_contract_id import HashIDPreimageContractID -from .hash_id_preimage_operation_id import HashIDPreimageOperationID -from .hash_id_preimage_revoke_id import HashIDPreimageRevokeID -from .hash_id_preimage_soroban_authorization import HashIDPreimageSorobanAuthorization -from .hello import Hello -from .hmac_sha256_key import HmacSha256Key -from .hmac_sha256_mac import HmacSha256Mac -from .host_function import HostFunction +from .stellar_message import StellarMessage +from .authenticated_message_v0 import AuthenticatedMessageV0 +from .authenticated_message import AuthenticatedMessage +from .liquidity_pool_parameters import LiquidityPoolParameters +from .muxed_account_med25519 import MuxedAccountMed25519 +from .muxed_account import MuxedAccount +from .decorated_signature import DecoratedSignature +from .operation_type import OperationType +from .create_account_op import CreateAccountOp +from .payment_op import PaymentOp +from .path_payment_strict_receive_op import PathPaymentStrictReceiveOp +from .path_payment_strict_send_op import PathPaymentStrictSendOp +from .manage_sell_offer_op import ManageSellOfferOp +from .manage_buy_offer_op import ManageBuyOfferOp +from .create_passive_sell_offer_op import CreatePassiveSellOfferOp +from .set_options_op import SetOptionsOp +from .change_trust_asset import ChangeTrustAsset +from .change_trust_op import ChangeTrustOp +from .allow_trust_op import AllowTrustOp +from .manage_data_op import ManageDataOp +from .bump_sequence_op import BumpSequenceOp +from .create_claimable_balance_op import CreateClaimableBalanceOp +from .claim_claimable_balance_op import ClaimClaimableBalanceOp +from .begin_sponsoring_future_reserves_op import BeginSponsoringFutureReservesOp +from .revoke_sponsorship_type import RevokeSponsorshipType +from .revoke_sponsorship_op_signer import RevokeSponsorshipOpSigner +from .revoke_sponsorship_op import RevokeSponsorshipOp +from .clawback_op import ClawbackOp +from .clawback_claimable_balance_op import ClawbackClaimableBalanceOp +from .set_trust_line_flags_op import SetTrustLineFlagsOp +from .liquidity_pool_deposit_op import LiquidityPoolDepositOp +from .liquidity_pool_withdraw_op import LiquidityPoolWithdrawOp from .host_function_type import HostFunctionType -from .inflation_payout import InflationPayout -from .inflation_result import InflationResult -from .inflation_result_code import InflationResultCode -from .inner_transaction_result import InnerTransactionResult -from .inner_transaction_result_ext import InnerTransactionResultExt -from .inner_transaction_result_pair import InnerTransactionResultPair -from .inner_transaction_result_result import InnerTransactionResultResult -from .int32 import Int32 -from .int64 import Int64 -from .int128_parts import Int128Parts -from .int256_parts import Int256Parts +from .contract_id_preimage_type import ContractIDPreimageType +from .contract_id_preimage_from_address import ContractIDPreimageFromAddress +from .contract_id_preimage import ContractIDPreimage +from .create_contract_args import CreateContractArgs from .invoke_contract_args import InvokeContractArgs +from .host_function import HostFunction +from .soroban_authorized_function_type import SorobanAuthorizedFunctionType +from .soroban_authorized_function import SorobanAuthorizedFunction +from .soroban_authorized_invocation import SorobanAuthorizedInvocation +from .soroban_address_credentials import SorobanAddressCredentials +from .soroban_credentials_type import SorobanCredentialsType +from .soroban_credentials import SorobanCredentials +from .soroban_authorization_entry import SorobanAuthorizationEntry from .invoke_host_function_op import InvokeHostFunctionOp -from .invoke_host_function_result import InvokeHostFunctionResult -from .invoke_host_function_result_code import InvokeHostFunctionResultCode -from .invoke_host_function_success_pre_image import InvokeHostFunctionSuccessPreImage -from .ip_addr_type import IPAddrType +from .bump_footprint_expiration_op import BumpFootprintExpirationOp +from .restore_footprint_op import RestoreFootprintOp +from .operation_body import OperationBody +from .operation import Operation +from .hash_id_preimage_operation_id import HashIDPreimageOperationID +from .hash_id_preimage_revoke_id import HashIDPreimageRevokeID +from .hash_id_preimage_contract_id import HashIDPreimageContractID +from .hash_id_preimage_soroban_authorization import HashIDPreimageSorobanAuthorization +from .hash_id_preimage import HashIDPreimage +from .memo_type import MemoType +from .memo import Memo +from .time_bounds import TimeBounds from .ledger_bounds import LedgerBounds -from .ledger_close_meta import LedgerCloseMeta -from .ledger_close_meta_v0 import LedgerCloseMetaV0 -from .ledger_close_meta_v1 import LedgerCloseMetaV1 -from .ledger_close_meta_v2 import LedgerCloseMetaV2 -from .ledger_close_value_signature import LedgerCloseValueSignature -from .ledger_entry import LedgerEntry -from .ledger_entry_change import LedgerEntryChange -from .ledger_entry_change_type import LedgerEntryChangeType -from .ledger_entry_changes import LedgerEntryChanges -from .ledger_entry_data import LedgerEntryData -from .ledger_entry_ext import LedgerEntryExt -from .ledger_entry_extension_v1 import LedgerEntryExtensionV1 -from .ledger_entry_extension_v1_ext import LedgerEntryExtensionV1Ext -from .ledger_entry_type import LedgerEntryType +from .preconditions_v2 import PreconditionsV2 +from .precondition_type import PreconditionType +from .preconditions import Preconditions from .ledger_footprint import LedgerFootprint -from .ledger_header import LedgerHeader -from .ledger_header_ext import LedgerHeaderExt -from .ledger_header_extension_v1 import LedgerHeaderExtensionV1 -from .ledger_header_extension_v1_ext import LedgerHeaderExtensionV1Ext -from .ledger_header_flags import LedgerHeaderFlags -from .ledger_header_history_entry import LedgerHeaderHistoryEntry -from .ledger_header_history_entry_ext import LedgerHeaderHistoryEntryExt -from .ledger_key import LedgerKey -from .ledger_key_account import LedgerKeyAccount -from .ledger_key_claimable_balance import LedgerKeyClaimableBalance -from .ledger_key_config_setting import LedgerKeyConfigSetting -from .ledger_key_contract_code import LedgerKeyContractCode -from .ledger_key_contract_data import LedgerKeyContractData -from .ledger_key_data import LedgerKeyData -from .ledger_key_expiration import LedgerKeyExpiration -from .ledger_key_liquidity_pool import LedgerKeyLiquidityPool -from .ledger_key_offer import LedgerKeyOffer -from .ledger_key_trust_line import LedgerKeyTrustLine -from .ledger_scp_messages import LedgerSCPMessages -from .ledger_upgrade import LedgerUpgrade -from .ledger_upgrade_type import LedgerUpgradeType -from .liabilities import Liabilities -from .liquidity_pool_constant_product_parameters import ( - LiquidityPoolConstantProductParameters, -) -from .liquidity_pool_deposit_op import LiquidityPoolDepositOp -from .liquidity_pool_deposit_result import LiquidityPoolDepositResult -from .liquidity_pool_deposit_result_code import LiquidityPoolDepositResultCode -from .liquidity_pool_entry import LiquidityPoolEntry -from .liquidity_pool_entry_body import LiquidityPoolEntryBody -from .liquidity_pool_entry_constant_product import LiquidityPoolEntryConstantProduct -from .liquidity_pool_parameters import LiquidityPoolParameters -from .liquidity_pool_type import LiquidityPoolType -from .liquidity_pool_withdraw_op import LiquidityPoolWithdrawOp -from .liquidity_pool_withdraw_result import LiquidityPoolWithdrawResult -from .liquidity_pool_withdraw_result_code import LiquidityPoolWithdrawResultCode -from .manage_buy_offer_op import ManageBuyOfferOp -from .manage_buy_offer_result import ManageBuyOfferResult -from .manage_buy_offer_result_code import ManageBuyOfferResultCode -from .manage_data_op import ManageDataOp -from .manage_data_result import ManageDataResult -from .manage_data_result_code import ManageDataResultCode +from .soroban_resources import SorobanResources +from .soroban_transaction_data import SorobanTransactionData +from .transaction_v0_ext import TransactionV0Ext +from .transaction_v0 import TransactionV0 +from .transaction_v0_envelope import TransactionV0Envelope +from .transaction_ext import TransactionExt +from .transaction import Transaction +from .transaction_v1_envelope import TransactionV1Envelope +from .fee_bump_transaction_inner_tx import FeeBumpTransactionInnerTx +from .fee_bump_transaction_ext import FeeBumpTransactionExt +from .fee_bump_transaction import FeeBumpTransaction +from .fee_bump_transaction_envelope import FeeBumpTransactionEnvelope +from .transaction_envelope import TransactionEnvelope +from .transaction_signature_payload_tagged_transaction import TransactionSignaturePayloadTaggedTransaction +from .transaction_signature_payload import TransactionSignaturePayload +from .claim_atom_type import ClaimAtomType +from .claim_offer_atom_v0 import ClaimOfferAtomV0 +from .claim_offer_atom import ClaimOfferAtom +from .claim_liquidity_atom import ClaimLiquidityAtom +from .claim_atom import ClaimAtom +from .create_account_result_code import CreateAccountResultCode +from .create_account_result import CreateAccountResult +from .payment_result_code import PaymentResultCode +from .payment_result import PaymentResult +from .path_payment_strict_receive_result_code import PathPaymentStrictReceiveResultCode +from .simple_payment_result import SimplePaymentResult +from .path_payment_strict_receive_result_success import PathPaymentStrictReceiveResultSuccess +from .path_payment_strict_receive_result import PathPaymentStrictReceiveResult +from .path_payment_strict_send_result_code import PathPaymentStrictSendResultCode +from .path_payment_strict_send_result_success import PathPaymentStrictSendResultSuccess +from .path_payment_strict_send_result import PathPaymentStrictSendResult +from .manage_sell_offer_result_code import ManageSellOfferResultCode from .manage_offer_effect import ManageOfferEffect -from .manage_offer_success_result import ManageOfferSuccessResult from .manage_offer_success_result_offer import ManageOfferSuccessResultOffer -from .manage_sell_offer_op import ManageSellOfferOp +from .manage_offer_success_result import ManageOfferSuccessResult from .manage_sell_offer_result import ManageSellOfferResult -from .manage_sell_offer_result_code import ManageSellOfferResultCode -from .memo import Memo -from .memo_type import MemoType -from .message_type import MessageType -from .muxed_account import MuxedAccount -from .muxed_account_med25519 import MuxedAccountMed25519 -from .node_id import NodeID -from .offer_entry import OfferEntry -from .offer_entry_ext import OfferEntryExt -from .offer_entry_flags import OfferEntryFlags -from .operation import Operation -from .operation_body import OperationBody -from .operation_meta import OperationMeta -from .operation_result import OperationResult +from .manage_buy_offer_result_code import ManageBuyOfferResultCode +from .manage_buy_offer_result import ManageBuyOfferResult +from .set_options_result_code import SetOptionsResultCode +from .set_options_result import SetOptionsResult +from .change_trust_result_code import ChangeTrustResultCode +from .change_trust_result import ChangeTrustResult +from .allow_trust_result_code import AllowTrustResultCode +from .allow_trust_result import AllowTrustResult +from .account_merge_result_code import AccountMergeResultCode +from .account_merge_result import AccountMergeResult +from .inflation_result_code import InflationResultCode +from .inflation_payout import InflationPayout +from .inflation_result import InflationResult +from .manage_data_result_code import ManageDataResultCode +from .manage_data_result import ManageDataResult +from .bump_sequence_result_code import BumpSequenceResultCode +from .bump_sequence_result import BumpSequenceResult +from .create_claimable_balance_result_code import CreateClaimableBalanceResultCode +from .create_claimable_balance_result import CreateClaimableBalanceResult +from .claim_claimable_balance_result_code import ClaimClaimableBalanceResultCode +from .claim_claimable_balance_result import ClaimClaimableBalanceResult +from .begin_sponsoring_future_reserves_result_code import BeginSponsoringFutureReservesResultCode +from .begin_sponsoring_future_reserves_result import BeginSponsoringFutureReservesResult +from .end_sponsoring_future_reserves_result_code import EndSponsoringFutureReservesResultCode +from .end_sponsoring_future_reserves_result import EndSponsoringFutureReservesResult +from .revoke_sponsorship_result_code import RevokeSponsorshipResultCode +from .revoke_sponsorship_result import RevokeSponsorshipResult +from .clawback_result_code import ClawbackResultCode +from .clawback_result import ClawbackResult +from .clawback_claimable_balance_result_code import ClawbackClaimableBalanceResultCode +from .clawback_claimable_balance_result import ClawbackClaimableBalanceResult +from .set_trust_line_flags_result_code import SetTrustLineFlagsResultCode +from .set_trust_line_flags_result import SetTrustLineFlagsResult +from .liquidity_pool_deposit_result_code import LiquidityPoolDepositResultCode +from .liquidity_pool_deposit_result import LiquidityPoolDepositResult +from .liquidity_pool_withdraw_result_code import LiquidityPoolWithdrawResultCode +from .liquidity_pool_withdraw_result import LiquidityPoolWithdrawResult +from .invoke_host_function_result_code import InvokeHostFunctionResultCode +from .invoke_host_function_result import InvokeHostFunctionResult +from .bump_footprint_expiration_result_code import BumpFootprintExpirationResultCode +from .bump_footprint_expiration_result import BumpFootprintExpirationResult +from .restore_footprint_result_code import RestoreFootprintResultCode +from .restore_footprint_result import RestoreFootprintResult from .operation_result_code import OperationResultCode from .operation_result_tr import OperationResultTr -from .operation_type import OperationType -from .path_payment_strict_receive_op import PathPaymentStrictReceiveOp -from .path_payment_strict_receive_result import PathPaymentStrictReceiveResult -from .path_payment_strict_receive_result_code import PathPaymentStrictReceiveResultCode -from .path_payment_strict_receive_result_success import ( - PathPaymentStrictReceiveResultSuccess, -) -from .path_payment_strict_send_op import PathPaymentStrictSendOp -from .path_payment_strict_send_result import PathPaymentStrictSendResult -from .path_payment_strict_send_result_code import PathPaymentStrictSendResultCode -from .path_payment_strict_send_result_success import PathPaymentStrictSendResultSuccess -from .payment_op import PaymentOp -from .payment_result import PaymentResult -from .payment_result_code import PaymentResultCode -from .peer_address import PeerAddress -from .peer_address_ip import PeerAddressIp -from .peer_stat_list import PeerStatList -from .peer_stats import PeerStats -from .persisted_scp_state import PersistedSCPState -from .persisted_scp_state_v0 import PersistedSCPStateV0 -from .persisted_scp_state_v1 import PersistedSCPStateV1 -from .pool_id import PoolID -from .precondition_type import PreconditionType -from .preconditions import Preconditions -from .preconditions_v2 import PreconditionsV2 -from .price import Price -from .public_key import PublicKey +from .operation_result import OperationResult +from .transaction_result_code import TransactionResultCode +from .inner_transaction_result_result import InnerTransactionResultResult +from .inner_transaction_result_ext import InnerTransactionResultExt +from .inner_transaction_result import InnerTransactionResult +from .inner_transaction_result_pair import InnerTransactionResultPair +from .transaction_result_result import TransactionResultResult +from .transaction_result_ext import TransactionResultExt +from .transaction_result import TransactionResult +from .hash import Hash +from .uint256 import Uint256 +from .uint32 import Uint32 +from .int32 import Int32 +from .uint64 import Uint64 +from .int64 import Int64 +from .time_point import TimePoint +from .duration import Duration +from .extension_point import ExtensionPoint +from .crypto_key_type import CryptoKeyType from .public_key_type import PublicKeyType -from .restore_footprint_op import RestoreFootprintOp -from .restore_footprint_result import RestoreFootprintResult -from .restore_footprint_result_code import RestoreFootprintResultCode -from .revoke_sponsorship_op import RevokeSponsorshipOp -from .revoke_sponsorship_op_signer import RevokeSponsorshipOpSigner -from .revoke_sponsorship_result import RevokeSponsorshipResult -from .revoke_sponsorship_result_code import RevokeSponsorshipResultCode -from .revoke_sponsorship_type import RevokeSponsorshipType -from .sc_address import SCAddress -from .sc_address_type import SCAddressType -from .sc_bytes import SCBytes -from .sc_contract_instance import SCContractInstance -from .sc_env_meta_entry import SCEnvMetaEntry +from .signer_key_type import SignerKeyType +from .public_key import PublicKey +from .signer_key_ed25519_signed_payload import SignerKeyEd25519SignedPayload +from .signer_key import SignerKey +from .signature import Signature +from .signature_hint import SignatureHint +from .node_id import NodeID +from .account_id import AccountID +from .curve25519_secret import Curve25519Secret +from .curve25519_public import Curve25519Public +from .hmac_sha256_key import HmacSha256Key +from .hmac_sha256_mac import HmacSha256Mac from .sc_env_meta_kind import SCEnvMetaKind -from .sc_error import SCError -from .sc_error_code import SCErrorCode -from .sc_error_type import SCErrorType -from .sc_map import SCMap -from .sc_map_entry import SCMapEntry -from .sc_meta_entry import SCMetaEntry -from .sc_meta_kind import SCMetaKind +from .sc_env_meta_entry import SCEnvMetaEntry from .sc_meta_v0 import SCMetaV0 -from .sc_nonce_key import SCNonceKey -from .sc_spec_entry import SCSpecEntry -from .sc_spec_entry_kind import SCSpecEntryKind -from .sc_spec_function_input_v0 import SCSpecFunctionInputV0 -from .sc_spec_function_v0 import SCSpecFunctionV0 +from .sc_meta_kind import SCMetaKind +from .sc_meta_entry import SCMetaEntry from .sc_spec_type import SCSpecType -from .sc_spec_type_bytes_n import SCSpecTypeBytesN -from .sc_spec_type_def import SCSpecTypeDef -from .sc_spec_type_map import SCSpecTypeMap from .sc_spec_type_option import SCSpecTypeOption from .sc_spec_type_result import SCSpecTypeResult +from .sc_spec_type_vec import SCSpecTypeVec +from .sc_spec_type_map import SCSpecTypeMap from .sc_spec_type_tuple import SCSpecTypeTuple +from .sc_spec_type_bytes_n import SCSpecTypeBytesN from .sc_spec_type_udt import SCSpecTypeUDT -from .sc_spec_type_vec import SCSpecTypeVec -from .sc_spec_udt_enum_case_v0 import SCSpecUDTEnumCaseV0 -from .sc_spec_udt_enum_v0 import SCSpecUDTEnumV0 -from .sc_spec_udt_error_enum_case_v0 import SCSpecUDTErrorEnumCaseV0 -from .sc_spec_udt_error_enum_v0 import SCSpecUDTErrorEnumV0 +from .sc_spec_type_def import SCSpecTypeDef from .sc_spec_udt_struct_field_v0 import SCSpecUDTStructFieldV0 from .sc_spec_udt_struct_v0 import SCSpecUDTStructV0 +from .sc_spec_udt_union_case_void_v0 import SCSpecUDTUnionCaseVoidV0 from .sc_spec_udt_union_case_tuple_v0 import SCSpecUDTUnionCaseTupleV0 -from .sc_spec_udt_union_case_v0 import SCSpecUDTUnionCaseV0 from .sc_spec_udt_union_case_v0_kind import SCSpecUDTUnionCaseV0Kind -from .sc_spec_udt_union_case_void_v0 import SCSpecUDTUnionCaseVoidV0 +from .sc_spec_udt_union_case_v0 import SCSpecUDTUnionCaseV0 from .sc_spec_udt_union_v0 import SCSpecUDTUnionV0 +from .sc_spec_udt_enum_case_v0 import SCSpecUDTEnumCaseV0 +from .sc_spec_udt_enum_v0 import SCSpecUDTEnumV0 +from .sc_spec_udt_error_enum_case_v0 import SCSpecUDTErrorEnumCaseV0 +from .sc_spec_udt_error_enum_v0 import SCSpecUDTErrorEnumV0 +from .sc_spec_function_input_v0 import SCSpecFunctionInputV0 +from .sc_spec_function_v0 import SCSpecFunctionV0 +from .sc_spec_entry_kind import SCSpecEntryKind +from .sc_spec_entry import SCSpecEntry +from .sc_val_type import SCValType +from .sc_error_type import SCErrorType +from .sc_error_code import SCErrorCode +from .sc_error import SCError +from .u_int128_parts import UInt128Parts +from .int128_parts import Int128Parts +from .u_int256_parts import UInt256Parts +from .int256_parts import Int256Parts +from .contract_executable_type import ContractExecutableType +from .contract_executable import ContractExecutable +from .sc_address_type import SCAddressType +from .sc_address import SCAddress +from .sc_vec import SCVec +from .sc_map import SCMap +from .sc_bytes import SCBytes from .sc_string import SCString from .sc_symbol import SCSymbol +from .sc_nonce_key import SCNonceKey +from .sc_contract_instance import SCContractInstance from .sc_val import SCVal -from .sc_val_type import SCValType -from .sc_vec import SCVec -from .scp_ballot import SCPBallot -from .scp_envelope import SCPEnvelope -from .scp_history_entry import SCPHistoryEntry -from .scp_history_entry_v0 import SCPHistoryEntryV0 -from .scp_nomination import SCPNomination -from .scp_quorum_set import SCPQuorumSet -from .scp_statement import SCPStatement -from .scp_statement_confirm import SCPStatementConfirm -from .scp_statement_externalize import SCPStatementExternalize -from .scp_statement_pledges import SCPStatementPledges -from .scp_statement_prepare import SCPStatementPrepare -from .scp_statement_type import SCPStatementType -from .send_more import SendMore -from .send_more_extended import SendMoreExtended -from .sequence_number import SequenceNumber -from .set_options_op import SetOptionsOp -from .set_options_result import SetOptionsResult -from .set_options_result_code import SetOptionsResultCode -from .set_trust_line_flags_op import SetTrustLineFlagsOp -from .set_trust_line_flags_result import SetTrustLineFlagsResult -from .set_trust_line_flags_result_code import SetTrustLineFlagsResultCode -from .signature import Signature -from .signature_hint import SignatureHint -from .signed_survey_request_message import SignedSurveyRequestMessage -from .signed_survey_response_message import SignedSurveyResponseMessage -from .signer import Signer -from .signer_key import SignerKey -from .signer_key_ed25519_signed_payload import SignerKeyEd25519SignedPayload -from .signer_key_type import SignerKeyType -from .simple_payment_result import SimplePaymentResult -from .soroban_address_credentials import SorobanAddressCredentials -from .soroban_authorization_entry import SorobanAuthorizationEntry -from .soroban_authorized_function import SorobanAuthorizedFunction -from .soroban_authorized_function_type import SorobanAuthorizedFunctionType -from .soroban_authorized_invocation import SorobanAuthorizedInvocation -from .soroban_credentials import SorobanCredentials -from .soroban_credentials_type import SorobanCredentialsType -from .soroban_resources import SorobanResources -from .soroban_transaction_data import SorobanTransactionData -from .soroban_transaction_meta import SorobanTransactionMeta -from .sponsorship_descriptor import SponsorshipDescriptor -from .state_expiration_settings import StateExpirationSettings -from .stellar_message import StellarMessage -from .stellar_value import StellarValue -from .stellar_value_ext import StellarValueExt -from .stellar_value_type import StellarValueType +from .sc_map_entry import SCMapEntry from .stored_transaction_set import StoredTransactionSet -from .string32 import String32 -from .string64 import String64 -from .survey_message_command_type import SurveyMessageCommandType -from .survey_message_response_type import SurveyMessageResponseType -from .survey_request_message import SurveyRequestMessage -from .survey_response_body import SurveyResponseBody -from .survey_response_message import SurveyResponseMessage -from .threshold_indexes import ThresholdIndexes -from .thresholds import Thresholds -from .time_bounds import TimeBounds -from .time_point import TimePoint -from .topology_response_body_v0 import TopologyResponseBodyV0 -from .topology_response_body_v1 import TopologyResponseBodyV1 -from .transaction import Transaction -from .transaction_envelope import TransactionEnvelope -from .transaction_ext import TransactionExt -from .transaction_history_entry import TransactionHistoryEntry -from .transaction_history_entry_ext import TransactionHistoryEntryExt -from .transaction_history_result_entry import TransactionHistoryResultEntry -from .transaction_history_result_entry_ext import TransactionHistoryResultEntryExt -from .transaction_meta import TransactionMeta -from .transaction_meta_v1 import TransactionMetaV1 -from .transaction_meta_v2 import TransactionMetaV2 -from .transaction_meta_v3 import TransactionMetaV3 -from .transaction_phase import TransactionPhase -from .transaction_result import TransactionResult -from .transaction_result_code import TransactionResultCode -from .transaction_result_ext import TransactionResultExt -from .transaction_result_meta import TransactionResultMeta -from .transaction_result_pair import TransactionResultPair -from .transaction_result_result import TransactionResultResult -from .transaction_result_set import TransactionResultSet -from .transaction_set import TransactionSet -from .transaction_set_v1 import TransactionSetV1 -from .transaction_signature_payload import TransactionSignaturePayload -from .transaction_signature_payload_tagged_transaction import ( - TransactionSignaturePayloadTaggedTransaction, -) -from .transaction_v0 import TransactionV0 -from .transaction_v0_envelope import TransactionV0Envelope -from .transaction_v0_ext import TransactionV0Ext -from .transaction_v1_envelope import TransactionV1Envelope -from .trust_line_asset import TrustLineAsset -from .trust_line_entry import TrustLineEntry -from .trust_line_entry_ext import TrustLineEntryExt -from .trust_line_entry_extension_v2 import TrustLineEntryExtensionV2 -from .trust_line_entry_extension_v2_ext import TrustLineEntryExtensionV2Ext -from .trust_line_entry_v1 import TrustLineEntryV1 -from .trust_line_entry_v1_ext import TrustLineEntryV1Ext -from .trust_line_flags import TrustLineFlags -from .tx_advert_vector import TxAdvertVector -from .tx_demand_vector import TxDemandVector -from .tx_set_component import TxSetComponent -from .tx_set_component_txs_maybe_discounted_fee import ( - TxSetComponentTxsMaybeDiscountedFee, -) -from .tx_set_component_type import TxSetComponentType -from .u_int128_parts import UInt128Parts -from .u_int256_parts import UInt256Parts -from .uint32 import Uint32 -from .uint64 import Uint64 -from .uint256 import Uint256 -from .upgrade_entry_meta import UpgradeEntryMeta -from .upgrade_type import UpgradeType -from .value import Value +from .persisted_scp_state_v0 import PersistedSCPStateV0 +from .persisted_scp_state_v1 import PersistedSCPStateV1 +from .persisted_scp_state import PersistedSCPState +from .config_setting_contract_execution_lanes_v0 import ConfigSettingContractExecutionLanesV0 +from .config_setting_contract_compute_v0 import ConfigSettingContractComputeV0 +from .config_setting_contract_ledger_cost_v0 import ConfigSettingContractLedgerCostV0 +from .config_setting_contract_historical_data_v0 import ConfigSettingContractHistoricalDataV0 +from .config_setting_contract_events_v0 import ConfigSettingContractEventsV0 +from .config_setting_contract_bandwidth_v0 import ConfigSettingContractBandwidthV0 +from .contract_cost_type import ContractCostType +from .contract_cost_param_entry import ContractCostParamEntry +from .state_expiration_settings import StateExpirationSettings +from .eviction_iterator import EvictionIterator +from .contract_cost_params import ContractCostParams +from .config_setting_id import ConfigSettingID +from .config_setting_entry import ConfigSettingEntry diff --git a/stellar_sdk/xdr/account_entry.py b/stellar_sdk/xdr/account_entry.py index 5dcb08e7..5f0fac17 100644 --- a/stellar_sdk/xdr/account_entry.py +++ b/stellar_sdk/xdr/account_entry.py @@ -3,23 +3,23 @@ from __future__ import annotations import base64 -from typing import List, Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .account_entry_ext import AccountEntryExt from .account_id import AccountID -from .constants import * from .int64 import Int64 from .sequence_number import SequenceNumber -from .signer import Signer +from .uint32 import Uint32 +from .account_id import AccountID +from .uint32 import Uint32 from .string32 import String32 from .thresholds import Thresholds -from .uint32 import Uint32 - -__all__ = ["AccountEntry"] - - +from .signer import Signer +from .account_entry_ext import AccountEntryExt +__all__ = ['AccountEntry'] class AccountEntry: """ XDR Source Code:: @@ -53,7 +53,6 @@ class AccountEntry: ext; }; """ - def __init__( self, account_id: AccountID, @@ -69,9 +68,7 @@ def __init__( ) -> None: _expect_max_length = MAX_SIGNERS if signers and len(signers) > _expect_max_length: - raise ValueError( - f"The maximum length of `signers` should be {_expect_max_length}, but got {len(signers)}." - ) + raise ValueError(f"The maximum length of `signers` should be {_expect_max_length}, but got {len(signers)}.") self.account_id = account_id self.balance = balance self.seq_num = seq_num @@ -82,7 +79,6 @@ def __init__( self.thresholds = thresholds self.signers = signers self.ext = ext - def pack(self, packer: Packer) -> None: self.account_id.pack(packer) self.balance.pack(packer) @@ -100,7 +96,6 @@ def pack(self, packer: Packer) -> None: for signers_item in self.signers: signers_item.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountEntry: account_id = AccountID.unpack(unpacker) @@ -128,7 +123,6 @@ def unpack(cls, unpacker: Unpacker) -> AccountEntry: signers=signers, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -147,50 +141,23 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.account_id, - self.balance, - self.seq_num, - self.num_sub_entries, - self.inflation_dest, - self.flags, - self.home_domain, - self.thresholds, - self.signers, - self.ext, - ) - ) - + return hash((self.account_id, self.balance, self.seq_num, self.num_sub_entries, self.inflation_dest, self.flags, self.home_domain, self.thresholds, self.signers, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.account_id == other.account_id - and self.balance == other.balance - and self.seq_num == other.seq_num - and self.num_sub_entries == other.num_sub_entries - and self.inflation_dest == other.inflation_dest - and self.flags == other.flags - and self.home_domain == other.home_domain - and self.thresholds == other.thresholds - and self.signers == other.signers - and self.ext == other.ext - ) - + return self.account_id== other.account_id and self.balance== other.balance and self.seq_num== other.seq_num and self.num_sub_entries== other.num_sub_entries and self.inflation_dest== other.inflation_dest and self.flags== other.flags and self.home_domain== other.home_domain and self.thresholds== other.thresholds and self.signers== other.signers and self.ext== other.ext def __str__(self): out = [ - f"account_id={self.account_id}", - f"balance={self.balance}", - f"seq_num={self.seq_num}", - f"num_sub_entries={self.num_sub_entries}", - f"inflation_dest={self.inflation_dest}", - f"flags={self.flags}", - f"home_domain={self.home_domain}", - f"thresholds={self.thresholds}", - f"signers={self.signers}", - f"ext={self.ext}", + f'account_id={self.account_id}', + f'balance={self.balance}', + f'seq_num={self.seq_num}', + f'num_sub_entries={self.num_sub_entries}', + f'inflation_dest={self.inflation_dest}', + f'flags={self.flags}', + f'home_domain={self.home_domain}', + f'thresholds={self.thresholds}', + f'signers={self.signers}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/account_entry_ext.py b/stellar_sdk/xdr/account_entry_ext.py index f88df932..56ee726a 100644 --- a/stellar_sdk/xdr/account_entry_ext.py +++ b/stellar_sdk/xdr/account_entry_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_entry_extension_v1 import AccountEntryExtensionV1 -from .base import Integer - -__all__ = ["AccountEntryExt"] - - +__all__ = ['AccountEntryExt'] class AccountEntryExt: """ XDR Source Code:: @@ -24,7 +23,6 @@ class AccountEntryExt: AccountEntryExtensionV1 v1; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.v1 = v1 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v1 should not be None.") self.v1.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountEntryExt: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> AccountEntryExt: v1 = AccountEntryExtensionV1.unpack(unpacker) return cls(v=v, v1=v1) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,22 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v1, - ) - ) - + return hash((self.v, self.v1,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v1 == other.v1 - + return self.v== other.v and self.v1== other.v1 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v1={self.v1}") if self.v1 is not None else None + out.append(f'v={self.v}') + out.append(f'v1={self.v1}') if self.v1 is not None else None return f"" diff --git a/stellar_sdk/xdr/account_entry_extension_v1.py b/stellar_sdk/xdr/account_entry_extension_v1.py index e0d3ce5c..250ce816 100644 --- a/stellar_sdk/xdr/account_entry_extension_v1.py +++ b/stellar_sdk/xdr/account_entry_extension_v1.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .account_entry_extension_v1_ext import AccountEntryExtensionV1Ext from .liabilities import Liabilities - -__all__ = ["AccountEntryExtensionV1"] - - +from .account_entry_extension_v1_ext import AccountEntryExtensionV1Ext +__all__ = ['AccountEntryExtensionV1'] class AccountEntryExtensionV1: """ XDR Source Code:: @@ -30,7 +30,6 @@ class AccountEntryExtensionV1: ext; }; """ - def __init__( self, liabilities: Liabilities, @@ -38,11 +37,9 @@ def __init__( ) -> None: self.liabilities = liabilities self.ext = ext - def pack(self, packer: Packer) -> None: self.liabilities.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV1: liabilities = Liabilities.unpack(unpacker) @@ -51,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV1: liabilities=liabilities, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -70,23 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountEntryExtensionV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.liabilities, - self.ext, - ) - ) - + return hash((self.liabilities, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.liabilities == other.liabilities and self.ext == other.ext - + return self.liabilities== other.liabilities and self.ext== other.ext def __str__(self): out = [ - f"liabilities={self.liabilities}", - f"ext={self.ext}", + f'liabilities={self.liabilities}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/account_entry_extension_v1_ext.py b/stellar_sdk/xdr/account_entry_extension_v1_ext.py index fb9244b8..ff1b618a 100644 --- a/stellar_sdk/xdr/account_entry_extension_v1_ext.py +++ b/stellar_sdk/xdr/account_entry_extension_v1_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_entry_extension_v2 import AccountEntryExtensionV2 -from .base import Integer - -__all__ = ["AccountEntryExtensionV1Ext"] - - +__all__ = ['AccountEntryExtensionV1Ext'] class AccountEntryExtensionV1Ext: """ XDR Source Code:: @@ -24,7 +23,6 @@ class AccountEntryExtensionV1Ext: AccountEntryExtensionV2 v2; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.v2 = v2 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v2 should not be None.") self.v2.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV1Ext: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV1Ext: v2 = AccountEntryExtensionV2.unpack(unpacker) return cls(v=v, v2=v2) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,22 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountEntryExtensionV1Ext: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v2, - ) - ) - + return hash((self.v, self.v2,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v2 == other.v2 - + return self.v== other.v and self.v2== other.v2 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v2={self.v2}") if self.v2 is not None else None + out.append(f'v={self.v}') + out.append(f'v2={self.v2}') if self.v2 is not None else None return f"" diff --git a/stellar_sdk/xdr/account_entry_extension_v2.py b/stellar_sdk/xdr/account_entry_extension_v2.py index d1097a81..e5ca5058 100644 --- a/stellar_sdk/xdr/account_entry_extension_v2.py +++ b/stellar_sdk/xdr/account_entry_extension_v2.py @@ -3,18 +3,17 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .account_entry_extension_v2_ext import AccountEntryExtensionV2Ext +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .sponsorship_descriptor import SponsorshipDescriptor -from .uint32 import Uint32 - -__all__ = ["AccountEntryExtensionV2"] - +from .uint32 import Uint32 +from .uint32 import Uint32 +from .sponsorship_descriptor import SponsorshipDescriptor +from .account_entry_extension_v2_ext import AccountEntryExtensionV2Ext +__all__ = ['AccountEntryExtensionV2'] class AccountEntryExtensionV2: """ XDR Source Code:: @@ -35,7 +34,6 @@ class AccountEntryExtensionV2: ext; }; """ - def __init__( self, num_sponsored: Uint32, @@ -45,14 +43,11 @@ def __init__( ) -> None: _expect_max_length = MAX_SIGNERS if signer_sponsoring_i_ds and len(signer_sponsoring_i_ds) > _expect_max_length: - raise ValueError( - f"The maximum length of `signer_sponsoring_i_ds` should be {_expect_max_length}, but got {len(signer_sponsoring_i_ds)}." - ) + raise ValueError(f"The maximum length of `signer_sponsoring_i_ds` should be {_expect_max_length}, but got {len(signer_sponsoring_i_ds)}.") self.num_sponsored = num_sponsored self.num_sponsoring = num_sponsoring self.signer_sponsoring_i_ds = signer_sponsoring_i_ds self.ext = ext - def pack(self, packer: Packer) -> None: self.num_sponsored.pack(packer) self.num_sponsoring.pack(packer) @@ -60,7 +55,6 @@ def pack(self, packer: Packer) -> None: for signer_sponsoring_i_ds_item in self.signer_sponsoring_i_ds: signer_sponsoring_i_ds_item.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV2: num_sponsored = Uint32.unpack(unpacker) @@ -76,7 +70,6 @@ def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV2: signer_sponsoring_i_ds=signer_sponsoring_i_ds, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -95,32 +88,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountEntryExtensionV2: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.num_sponsored, - self.num_sponsoring, - self.signer_sponsoring_i_ds, - self.ext, - ) - ) - + return hash((self.num_sponsored, self.num_sponsoring, self.signer_sponsoring_i_ds, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.num_sponsored == other.num_sponsored - and self.num_sponsoring == other.num_sponsoring - and self.signer_sponsoring_i_ds == other.signer_sponsoring_i_ds - and self.ext == other.ext - ) - + return self.num_sponsored== other.num_sponsored and self.num_sponsoring== other.num_sponsoring and self.signer_sponsoring_i_ds== other.signer_sponsoring_i_ds and self.ext== other.ext def __str__(self): out = [ - f"num_sponsored={self.num_sponsored}", - f"num_sponsoring={self.num_sponsoring}", - f"signer_sponsoring_i_ds={self.signer_sponsoring_i_ds}", - f"ext={self.ext}", + f'num_sponsored={self.num_sponsored}', + f'num_sponsoring={self.num_sponsoring}', + f'signer_sponsoring_i_ds={self.signer_sponsoring_i_ds}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/account_entry_extension_v2_ext.py b/stellar_sdk/xdr/account_entry_extension_v2_ext.py index 4fc18ea0..e904bf80 100644 --- a/stellar_sdk/xdr/account_entry_extension_v2_ext.py +++ b/stellar_sdk/xdr/account_entry_extension_v2_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_entry_extension_v3 import AccountEntryExtensionV3 -from .base import Integer - -__all__ = ["AccountEntryExtensionV2Ext"] - - +__all__ = ['AccountEntryExtensionV2Ext'] class AccountEntryExtensionV2Ext: """ XDR Source Code:: @@ -24,7 +23,6 @@ class AccountEntryExtensionV2Ext: AccountEntryExtensionV3 v3; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.v3 = v3 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v3 should not be None.") self.v3.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV2Ext: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV2Ext: v3 = AccountEntryExtensionV3.unpack(unpacker) return cls(v=v, v3=v3) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,22 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountEntryExtensionV2Ext: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v3, - ) - ) - + return hash((self.v, self.v3,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v3 == other.v3 - + return self.v== other.v and self.v3== other.v3 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v3={self.v3}") if self.v3 is not None else None + out.append(f'v={self.v}') + out.append(f'v3={self.v3}') if self.v3 is not None else None return f"" diff --git a/stellar_sdk/xdr/account_entry_extension_v3.py b/stellar_sdk/xdr/account_entry_extension_v3.py index 94b6579d..eb70e158 100644 --- a/stellar_sdk/xdr/account_entry_extension_v3.py +++ b/stellar_sdk/xdr/account_entry_extension_v3.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .extension_point import ExtensionPoint -from .time_point import TimePoint from .uint32 import Uint32 - -__all__ = ["AccountEntryExtensionV3"] - - +from .time_point import TimePoint +__all__ = ['AccountEntryExtensionV3'] class AccountEntryExtensionV3: """ XDR Source Code:: @@ -30,7 +30,6 @@ class AccountEntryExtensionV3: TimePoint seqTime; }; """ - def __init__( self, ext: ExtensionPoint, @@ -40,12 +39,10 @@ def __init__( self.ext = ext self.seq_ledger = seq_ledger self.seq_time = seq_time - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.seq_ledger.pack(packer) self.seq_time.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV3: ext = ExtensionPoint.unpack(unpacker) @@ -56,7 +53,6 @@ def unpack(cls, unpacker: Unpacker) -> AccountEntryExtensionV3: seq_ledger=seq_ledger, seq_time=seq_time, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -75,29 +71,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountEntryExtensionV3: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.seq_ledger, - self.seq_time, - ) - ) - + return hash((self.ext, self.seq_ledger, self.seq_time,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.seq_ledger == other.seq_ledger - and self.seq_time == other.seq_time - ) - + return self.ext== other.ext and self.seq_ledger== other.seq_ledger and self.seq_time== other.seq_time def __str__(self): out = [ - f"ext={self.ext}", - f"seq_ledger={self.seq_ledger}", - f"seq_time={self.seq_time}", + f'ext={self.ext}', + f'seq_ledger={self.seq_ledger}', + f'seq_time={self.seq_time}', ] return f"" diff --git a/stellar_sdk/xdr/account_flags.py b/stellar_sdk/xdr/account_flags.py index a2a72fa0..1971c897 100644 --- a/stellar_sdk/xdr/account_flags.py +++ b/stellar_sdk/xdr/account_flags.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["AccountFlags"] - - +__all__ = ['AccountFlags'] class AccountFlags(IntEnum): """ XDR Source Code:: @@ -32,12 +32,10 @@ class AccountFlags(IntEnum): AUTH_CLAWBACK_ENABLED_FLAG = 0x8 }; """ - AUTH_REQUIRED_FLAG = 1 AUTH_REVOCABLE_FLAG = 2 AUTH_IMMUTABLE_FLAG = 4 AUTH_CLAWBACK_ENABLED_FLAG = 8 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -45,7 +43,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> AccountFlags: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/account_id.py b/stellar_sdk/xdr/account_id.py index eddbbfad..bff09579 100644 --- a/stellar_sdk/xdr/account_id.py +++ b/stellar_sdk/xdr/account_id.py @@ -3,32 +3,28 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .public_key import PublicKey - -__all__ = ["AccountID"] - - +__all__ = ['AccountID'] class AccountID: """ XDR Source Code:: typedef PublicKey AccountID; """ - def __init__(self, account_id: PublicKey) -> None: self.account_id = account_id - def pack(self, packer: Packer) -> None: self.account_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountID: account_id = PublicKey.unpack(unpacker) return cls(account_id) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +43,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountID: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.account_id) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/account_merge_result.py b/stellar_sdk/xdr/account_merge_result.py index c81a4f1b..be27b3b3 100644 --- a/stellar_sdk/xdr/account_merge_result.py +++ b/stellar_sdk/xdr/account_merge_result.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_merge_result_code import AccountMergeResultCode from .int64 import Int64 - -__all__ = ["AccountMergeResult"] - - +__all__ = ['AccountMergeResult'] class AccountMergeResult: """ XDR Source Code:: @@ -30,7 +30,6 @@ class AccountMergeResult: void; }; """ - def __init__( self, code: AccountMergeResultCode, @@ -38,7 +37,6 @@ def __init__( ) -> None: self.code = code self.source_account_balance = source_account_balance - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == AccountMergeResultCode.ACCOUNT_MERGE_SUCCESS: @@ -60,7 +58,6 @@ def pack(self, packer: Packer) -> None: return if self.code == AccountMergeResultCode.ACCOUNT_MERGE_IS_SPONSOR: return - @classmethod def unpack(cls, unpacker: Unpacker) -> AccountMergeResult: code = AccountMergeResultCode.unpack(unpacker) @@ -82,7 +79,6 @@ def unpack(cls, unpacker: Unpacker) -> AccountMergeResult: if code == AccountMergeResultCode.ACCOUNT_MERGE_IS_SPONSOR: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -101,27 +97,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AccountMergeResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.source_account_balance, - ) - ) - + return hash((self.code, self.source_account_balance,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.code == other.code - and self.source_account_balance == other.source_account_balance - ) - + return self.code== other.code and self.source_account_balance== other.source_account_balance def __str__(self): out = [] - out.append(f"code={self.code}") - out.append( - f"source_account_balance={self.source_account_balance}" - ) if self.source_account_balance is not None else None + out.append(f'code={self.code}') + out.append(f'source_account_balance={self.source_account_balance}') if self.source_account_balance is not None else None return f"" diff --git a/stellar_sdk/xdr/account_merge_result_code.py b/stellar_sdk/xdr/account_merge_result_code.py index 44f20e1b..3e68d396 100644 --- a/stellar_sdk/xdr/account_merge_result_code.py +++ b/stellar_sdk/xdr/account_merge_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["AccountMergeResultCode"] - - +__all__ = ['AccountMergeResultCode'] class AccountMergeResultCode(IntEnum): """ XDR Source Code:: @@ -29,7 +29,6 @@ class AccountMergeResultCode(IntEnum): ACCOUNT_MERGE_IS_SPONSOR = -7 // can't merge account that is a sponsor }; """ - ACCOUNT_MERGE_SUCCESS = 0 ACCOUNT_MERGE_MALFORMED = -1 ACCOUNT_MERGE_NO_ACCOUNT = -2 @@ -38,7 +37,6 @@ class AccountMergeResultCode(IntEnum): ACCOUNT_MERGE_SEQNUM_TOO_FAR = -5 ACCOUNT_MERGE_DEST_FULL = -6 ACCOUNT_MERGE_IS_SPONSOR = -7 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -46,7 +44,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> AccountMergeResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/allow_trust_op.py b/stellar_sdk/xdr/allow_trust_op.py index 2c46d32e..1f31e694 100644 --- a/stellar_sdk/xdr/allow_trust_op.py +++ b/stellar_sdk/xdr/allow_trust_op.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .asset_code import AssetCode from .uint32 import Uint32 - -__all__ = ["AllowTrustOp"] - - +__all__ = ['AllowTrustOp'] class AllowTrustOp: """ XDR Source Code:: @@ -26,7 +26,6 @@ class AllowTrustOp: uint32 authorize; }; """ - def __init__( self, trustor: AccountID, @@ -36,12 +35,10 @@ def __init__( self.trustor = trustor self.asset = asset self.authorize = authorize - def pack(self, packer: Packer) -> None: self.trustor.pack(packer) self.asset.pack(packer) self.authorize.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AllowTrustOp: trustor = AccountID.unpack(unpacker) @@ -52,7 +49,6 @@ def unpack(cls, unpacker: Unpacker) -> AllowTrustOp: asset=asset, authorize=authorize, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,29 +67,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AllowTrustOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.trustor, - self.asset, - self.authorize, - ) - ) - + return hash((self.trustor, self.asset, self.authorize,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.trustor == other.trustor - and self.asset == other.asset - and self.authorize == other.authorize - ) - + return self.trustor== other.trustor and self.asset== other.asset and self.authorize== other.authorize def __str__(self): out = [ - f"trustor={self.trustor}", - f"asset={self.asset}", - f"authorize={self.authorize}", + f'trustor={self.trustor}', + f'asset={self.asset}', + f'authorize={self.authorize}', ] return f"" diff --git a/stellar_sdk/xdr/allow_trust_result.py b/stellar_sdk/xdr/allow_trust_result.py index c07c88a2..3e36dcd6 100644 --- a/stellar_sdk/xdr/allow_trust_result.py +++ b/stellar_sdk/xdr/allow_trust_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .allow_trust_result_code import AllowTrustResultCode - -__all__ = ["AllowTrustResult"] - - +__all__ = ['AllowTrustResult'] class AllowTrustResult: """ XDR Source Code:: @@ -28,13 +28,11 @@ class AllowTrustResult: void; }; """ - def __init__( self, code: AllowTrustResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == AllowTrustResultCode.ALLOW_TRUST_SUCCESS: @@ -51,7 +49,6 @@ def pack(self, packer: Packer) -> None: return if self.code == AllowTrustResultCode.ALLOW_TRUST_LOW_RESERVE: return - @classmethod def unpack(cls, unpacker: Unpacker) -> AllowTrustResult: code = AllowTrustResultCode.unpack(unpacker) @@ -70,7 +67,6 @@ def unpack(cls, unpacker: Unpacker) -> AllowTrustResult: if code == AllowTrustResultCode.ALLOW_TRUST_LOW_RESERVE: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -89,16 +85,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AllowTrustResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/allow_trust_result_code.py b/stellar_sdk/xdr/allow_trust_result_code.py index 00746bf8..aa21de39 100644 --- a/stellar_sdk/xdr/allow_trust_result_code.py +++ b/stellar_sdk/xdr/allow_trust_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["AllowTrustResultCode"] - - +__all__ = ['AllowTrustResultCode'] class AllowTrustResultCode(IntEnum): """ XDR Source Code:: @@ -29,7 +29,6 @@ class AllowTrustResultCode(IntEnum): // on revoke due to low reserves }; """ - ALLOW_TRUST_SUCCESS = 0 ALLOW_TRUST_MALFORMED = -1 ALLOW_TRUST_NO_TRUST_LINE = -2 @@ -37,7 +36,6 @@ class AllowTrustResultCode(IntEnum): ALLOW_TRUST_CANT_REVOKE = -4 ALLOW_TRUST_SELF_NOT_ALLOWED = -5 ALLOW_TRUST_LOW_RESERVE = -6 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -45,7 +43,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> AllowTrustResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/alpha_num12.py b/stellar_sdk/xdr/alpha_num12.py index ec5192f8..9cab9d08 100644 --- a/stellar_sdk/xdr/alpha_num12.py +++ b/stellar_sdk/xdr/alpha_num12.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .account_id import AccountID from .asset_code12 import AssetCode12 - -__all__ = ["AlphaNum12"] - - +from .account_id import AccountID +__all__ = ['AlphaNum12'] class AlphaNum12: """ XDR Source Code:: @@ -22,7 +22,6 @@ class AlphaNum12: AccountID issuer; }; """ - def __init__( self, asset_code: AssetCode12, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.asset_code = asset_code self.issuer = issuer - def pack(self, packer: Packer) -> None: self.asset_code.pack(packer) self.issuer.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AlphaNum12: asset_code = AssetCode12.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> AlphaNum12: asset_code=asset_code, issuer=issuer, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AlphaNum12: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.asset_code, - self.issuer, - ) - ) - + return hash((self.asset_code, self.issuer,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.asset_code == other.asset_code and self.issuer == other.issuer - + return self.asset_code== other.asset_code and self.issuer== other.issuer def __str__(self): out = [ - f"asset_code={self.asset_code}", - f"issuer={self.issuer}", + f'asset_code={self.asset_code}', + f'issuer={self.issuer}', ] return f"" diff --git a/stellar_sdk/xdr/alpha_num4.py b/stellar_sdk/xdr/alpha_num4.py index 6ee0afb2..a50efb18 100644 --- a/stellar_sdk/xdr/alpha_num4.py +++ b/stellar_sdk/xdr/alpha_num4.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .account_id import AccountID from .asset_code4 import AssetCode4 - -__all__ = ["AlphaNum4"] - - +from .account_id import AccountID +__all__ = ['AlphaNum4'] class AlphaNum4: """ XDR Source Code:: @@ -22,7 +22,6 @@ class AlphaNum4: AccountID issuer; }; """ - def __init__( self, asset_code: AssetCode4, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.asset_code = asset_code self.issuer = issuer - def pack(self, packer: Packer) -> None: self.asset_code.pack(packer) self.issuer.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AlphaNum4: asset_code = AssetCode4.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> AlphaNum4: asset_code=asset_code, issuer=issuer, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AlphaNum4: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.asset_code, - self.issuer, - ) - ) - + return hash((self.asset_code, self.issuer,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.asset_code == other.asset_code and self.issuer == other.issuer - + return self.asset_code== other.asset_code and self.issuer== other.issuer def __str__(self): out = [ - f"asset_code={self.asset_code}", - f"issuer={self.issuer}", + f'asset_code={self.asset_code}', + f'issuer={self.issuer}', ] return f"" diff --git a/stellar_sdk/xdr/asset.py b/stellar_sdk/xdr/asset.py index 71412b58..73f68ab9 100644 --- a/stellar_sdk/xdr/asset.py +++ b/stellar_sdk/xdr/asset.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .asset_type import AssetType from .alpha_num4 import AlphaNum4 from .alpha_num12 import AlphaNum12 -from .asset_type import AssetType - -__all__ = ["Asset"] - - +__all__ = ['Asset'] class Asset: """ XDR Source Code:: @@ -31,7 +31,6 @@ class Asset: // add other asset types here in the future }; """ - def __init__( self, type: AssetType, @@ -41,7 +40,6 @@ def __init__( self.type = type self.alpha_num4 = alpha_num4 self.alpha_num12 = alpha_num12 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == AssetType.ASSET_TYPE_NATIVE: @@ -56,7 +54,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("alpha_num12 should not be None.") self.alpha_num12.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> Asset: type = AssetType.unpack(unpacker) @@ -69,7 +66,6 @@ def unpack(cls, unpacker: Unpacker) -> Asset: alpha_num12 = AlphaNum12.unpack(unpacker) return cls(type=type, alpha_num12=alpha_num12) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -88,32 +84,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Asset: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.alpha_num4, - self.alpha_num12, - ) - ) - + return hash((self.type, self.alpha_num4, self.alpha_num12,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.alpha_num4 == other.alpha_num4 - and self.alpha_num12 == other.alpha_num12 - ) - + return self.type== other.type and self.alpha_num4== other.alpha_num4 and self.alpha_num12== other.alpha_num12 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"alpha_num4={self.alpha_num4}" - ) if self.alpha_num4 is not None else None - out.append( - f"alpha_num12={self.alpha_num12}" - ) if self.alpha_num12 is not None else None + out.append(f'type={self.type}') + out.append(f'alpha_num4={self.alpha_num4}') if self.alpha_num4 is not None else None + out.append(f'alpha_num12={self.alpha_num12}') if self.alpha_num12 is not None else None return f"" diff --git a/stellar_sdk/xdr/asset_code.py b/stellar_sdk/xdr/asset_code.py index 015cd2d2..b7b77d31 100644 --- a/stellar_sdk/xdr/asset_code.py +++ b/stellar_sdk/xdr/asset_code.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .asset_type import AssetType from .asset_code4 import AssetCode4 from .asset_code12 import AssetCode12 -from .asset_type import AssetType - -__all__ = ["AssetCode"] - - +__all__ = ['AssetCode'] class AssetCode: """ XDR Source Code:: @@ -28,7 +28,6 @@ class AssetCode: // add other asset types here in the future }; """ - def __init__( self, type: AssetType, @@ -38,7 +37,6 @@ def __init__( self.type = type self.asset_code4 = asset_code4 self.asset_code12 = asset_code12 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == AssetType.ASSET_TYPE_CREDIT_ALPHANUM4: @@ -51,7 +49,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("asset_code12 should not be None.") self.asset_code12.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> AssetCode: type = AssetType.unpack(unpacker) @@ -62,7 +59,6 @@ def unpack(cls, unpacker: Unpacker) -> AssetCode: asset_code12 = AssetCode12.unpack(unpacker) return cls(type=type, asset_code12=asset_code12) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -81,32 +77,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AssetCode: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.asset_code4, - self.asset_code12, - ) - ) - + return hash((self.type, self.asset_code4, self.asset_code12,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.asset_code4 == other.asset_code4 - and self.asset_code12 == other.asset_code12 - ) - + return self.type== other.type and self.asset_code4== other.asset_code4 and self.asset_code12== other.asset_code12 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"asset_code4={self.asset_code4}" - ) if self.asset_code4 is not None else None - out.append( - f"asset_code12={self.asset_code12}" - ) if self.asset_code12 is not None else None + out.append(f'type={self.type}') + out.append(f'asset_code4={self.asset_code4}') if self.asset_code4 is not None else None + out.append(f'asset_code12={self.asset_code12}') if self.asset_code12 is not None else None return f"" diff --git a/stellar_sdk/xdr/asset_code12.py b/stellar_sdk/xdr/asset_code12.py index f90d0fb3..11cb6147 100644 --- a/stellar_sdk/xdr/asset_code12.py +++ b/stellar_sdk/xdr/asset_code12.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["AssetCode12"] - - +__all__ = ['AssetCode12'] class AssetCode12: """ XDR Source Code:: typedef opaque AssetCode12[12]; """ - def __init__(self, asset_code12: bytes) -> None: self.asset_code12 = asset_code12 - def pack(self, packer: Packer) -> None: Opaque(self.asset_code12, 12, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AssetCode12: asset_code12 = Opaque.unpack(unpacker, 12, True) return cls(asset_code12) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AssetCode12: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.asset_code12) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/asset_code4.py b/stellar_sdk/xdr/asset_code4.py index fc439031..f2d508d3 100644 --- a/stellar_sdk/xdr/asset_code4.py +++ b/stellar_sdk/xdr/asset_code4.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["AssetCode4"] - - +__all__ = ['AssetCode4'] class AssetCode4: """ XDR Source Code:: typedef opaque AssetCode4[4]; """ - def __init__(self, asset_code4: bytes) -> None: self.asset_code4 = asset_code4 - def pack(self, packer: Packer) -> None: Opaque(self.asset_code4, 4, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AssetCode4: asset_code4 = Opaque.unpack(unpacker, 4, True) return cls(asset_code4) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AssetCode4: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.asset_code4) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/asset_type.py b/stellar_sdk/xdr/asset_type.py index ae030ae5..efbdb685 100644 --- a/stellar_sdk/xdr/asset_type.py +++ b/stellar_sdk/xdr/asset_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["AssetType"] - - +__all__ = ['AssetType'] class AssetType(IntEnum): """ XDR Source Code:: @@ -22,12 +22,10 @@ class AssetType(IntEnum): ASSET_TYPE_POOL_SHARE = 3 }; """ - ASSET_TYPE_NATIVE = 0 ASSET_TYPE_CREDIT_ALPHANUM4 = 1 ASSET_TYPE_CREDIT_ALPHANUM12 = 2 ASSET_TYPE_POOL_SHARE = 3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -35,7 +33,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> AssetType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/auth.py b/stellar_sdk/xdr/auth.py index 26e39510..b2f60b09 100644 --- a/stellar_sdk/xdr/auth.py +++ b/stellar_sdk/xdr/auth.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["Auth"] - - +__all__ = ['Auth'] class Auth: """ XDR Source Code:: @@ -20,23 +19,19 @@ class Auth: int flags; }; """ - def __init__( self, flags: int, ) -> None: self.flags = flags - def pack(self, packer: Packer) -> None: Integer(self.flags).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Auth: flags = Integer.unpack(unpacker) return cls( flags=flags, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +50,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Auth: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.flags,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.flags == other.flags - + return self.flags== other.flags def __str__(self): out = [ - f"flags={self.flags}", + f'flags={self.flags}', ] return f"" diff --git a/stellar_sdk/xdr/auth_cert.py b/stellar_sdk/xdr/auth_cert.py index 85c3e55d..13c4f724 100644 --- a/stellar_sdk/xdr/auth_cert.py +++ b/stellar_sdk/xdr/auth_cert.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .curve25519_public import Curve25519Public -from .signature import Signature from .uint64 import Uint64 - -__all__ = ["AuthCert"] - - +from .signature import Signature +__all__ = ['AuthCert'] class AuthCert: """ XDR Source Code:: @@ -24,7 +24,6 @@ class AuthCert: Signature sig; }; """ - def __init__( self, pubkey: Curve25519Public, @@ -34,12 +33,10 @@ def __init__( self.pubkey = pubkey self.expiration = expiration self.sig = sig - def pack(self, packer: Packer) -> None: self.pubkey.pack(packer) self.expiration.pack(packer) self.sig.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AuthCert: pubkey = Curve25519Public.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> AuthCert: expiration=expiration, sig=sig, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AuthCert: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.pubkey, - self.expiration, - self.sig, - ) - ) - + return hash((self.pubkey, self.expiration, self.sig,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.pubkey == other.pubkey - and self.expiration == other.expiration - and self.sig == other.sig - ) - + return self.pubkey== other.pubkey and self.expiration== other.expiration and self.sig== other.sig def __str__(self): out = [ - f"pubkey={self.pubkey}", - f"expiration={self.expiration}", - f"sig={self.sig}", + f'pubkey={self.pubkey}', + f'expiration={self.expiration}', + f'sig={self.sig}', ] return f"" diff --git a/stellar_sdk/xdr/authenticated_message.py b/stellar_sdk/xdr/authenticated_message.py index 8f5c2677..b3229ccc 100644 --- a/stellar_sdk/xdr/authenticated_message.py +++ b/stellar_sdk/xdr/authenticated_message.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .authenticated_message_v0 import AuthenticatedMessageV0 from .uint32 import Uint32 - -__all__ = ["AuthenticatedMessage"] - - +from .authenticated_message_v0 import AuthenticatedMessageV0 +__all__ = ['AuthenticatedMessage'] class AuthenticatedMessage: """ XDR Source Code:: @@ -27,7 +27,6 @@ class AuthenticatedMessage: } v0; }; """ - def __init__( self, v: Uint32, @@ -35,7 +34,6 @@ def __init__( ) -> None: self.v = v self.v0 = v0 - def pack(self, packer: Packer) -> None: self.v.pack(packer) if self.v == 0: @@ -43,7 +41,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v0 should not be None.") self.v0.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> AuthenticatedMessage: v = Uint32.unpack(unpacker) @@ -51,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> AuthenticatedMessage: v0 = AuthenticatedMessageV0.unpack(unpacker) return cls(v=v, v0=v0) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -70,22 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AuthenticatedMessage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v0, - ) - ) - + return hash((self.v, self.v0,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v0 == other.v0 - + return self.v== other.v and self.v0== other.v0 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v0={self.v0}") if self.v0 is not None else None + out.append(f'v={self.v}') + out.append(f'v0={self.v0}') if self.v0 is not None else None return f"" diff --git a/stellar_sdk/xdr/authenticated_message_v0.py b/stellar_sdk/xdr/authenticated_message_v0.py index db99e6e0..7ef3e2f8 100644 --- a/stellar_sdk/xdr/authenticated_message_v0.py +++ b/stellar_sdk/xdr/authenticated_message_v0.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .hmac_sha256_mac import HmacSha256Mac -from .stellar_message import StellarMessage from .uint64 import Uint64 - -__all__ = ["AuthenticatedMessageV0"] - - +from .stellar_message import StellarMessage +from .hmac_sha256_mac import HmacSha256Mac +__all__ = ['AuthenticatedMessageV0'] class AuthenticatedMessageV0: """ XDR Source Code:: @@ -24,7 +24,6 @@ class AuthenticatedMessageV0: HmacSha256Mac mac; } """ - def __init__( self, sequence: Uint64, @@ -34,12 +33,10 @@ def __init__( self.sequence = sequence self.message = message self.mac = mac - def pack(self, packer: Packer) -> None: self.sequence.pack(packer) self.message.pack(packer) self.mac.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> AuthenticatedMessageV0: sequence = Uint64.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> AuthenticatedMessageV0: message=message, mac=mac, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> AuthenticatedMessageV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.sequence, - self.message, - self.mac, - ) - ) - + return hash((self.sequence, self.message, self.mac,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.sequence == other.sequence - and self.message == other.message - and self.mac == other.mac - ) - + return self.sequence== other.sequence and self.message== other.message and self.mac== other.mac def __str__(self): out = [ - f"sequence={self.sequence}", - f"message={self.message}", - f"mac={self.mac}", + f'sequence={self.sequence}', + f'message={self.message}', + f'mac={self.mac}', ] return f"" diff --git a/stellar_sdk/xdr/begin_sponsoring_future_reserves_op.py b/stellar_sdk/xdr/begin_sponsoring_future_reserves_op.py index f05a5d2a..7d78cf65 100644 --- a/stellar_sdk/xdr/begin_sponsoring_future_reserves_op.py +++ b/stellar_sdk/xdr/begin_sponsoring_future_reserves_op.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID - -__all__ = ["BeginSponsoringFutureReservesOp"] - - +__all__ = ['BeginSponsoringFutureReservesOp'] class BeginSponsoringFutureReservesOp: """ XDR Source Code:: @@ -20,23 +20,19 @@ class BeginSponsoringFutureReservesOp: AccountID sponsoredID; }; """ - def __init__( self, sponsored_id: AccountID, ) -> None: self.sponsored_id = sponsored_id - def pack(self, packer: Packer) -> None: self.sponsored_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> BeginSponsoringFutureReservesOp: sponsored_id = AccountID.unpack(unpacker) return cls( sponsored_id=sponsored_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BeginSponsoringFutureReservesOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.sponsored_id,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.sponsored_id == other.sponsored_id - + return self.sponsored_id== other.sponsored_id def __str__(self): out = [ - f"sponsored_id={self.sponsored_id}", + f'sponsored_id={self.sponsored_id}', ] return f"" diff --git a/stellar_sdk/xdr/begin_sponsoring_future_reserves_result.py b/stellar_sdk/xdr/begin_sponsoring_future_reserves_result.py index 6dd976d3..cb7c7501 100644 --- a/stellar_sdk/xdr/begin_sponsoring_future_reserves_result.py +++ b/stellar_sdk/xdr/begin_sponsoring_future_reserves_result.py @@ -3,16 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .begin_sponsoring_future_reserves_result_code import ( - BeginSponsoringFutureReservesResultCode, -) - -__all__ = ["BeginSponsoringFutureReservesResult"] - - +from .begin_sponsoring_future_reserves_result_code import BeginSponsoringFutureReservesResultCode +__all__ = ['BeginSponsoringFutureReservesResult'] class BeginSponsoringFutureReservesResult: """ XDR Source Code:: @@ -28,61 +26,33 @@ class BeginSponsoringFutureReservesResult: void; }; """ - def __init__( self, code: BeginSponsoringFutureReservesResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) - if ( - self.code - == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS - ): + if self.code == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS: return - if ( - self.code - == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED - ): + if self.code == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED: return - if ( - self.code - == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED - ): + if self.code == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED: return - if ( - self.code - == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE - ): + if self.code == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE: return - @classmethod def unpack(cls, unpacker: Unpacker) -> BeginSponsoringFutureReservesResult: code = BeginSponsoringFutureReservesResultCode.unpack(unpacker) - if ( - code - == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS - ): + if code == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS: return cls(code=code) - if ( - code - == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED - ): + if code == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED: return cls(code=code) - if ( - code - == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED - ): + if code == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED: return cls(code=code) - if ( - code - == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE - ): + if code == BeginSponsoringFutureReservesResultCode.BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -101,16 +71,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BeginSponsoringFutureReservesResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/begin_sponsoring_future_reserves_result_code.py b/stellar_sdk/xdr/begin_sponsoring_future_reserves_result_code.py index 465b3434..589b101a 100644 --- a/stellar_sdk/xdr/begin_sponsoring_future_reserves_result_code.py +++ b/stellar_sdk/xdr/begin_sponsoring_future_reserves_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["BeginSponsoringFutureReservesResultCode"] - - +__all__ = ['BeginSponsoringFutureReservesResultCode'] class BeginSponsoringFutureReservesResultCode(IntEnum): """ XDR Source Code:: @@ -25,12 +25,10 @@ class BeginSponsoringFutureReservesResultCode(IntEnum): BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE = -3 }; """ - BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS = 0 BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED = -1 BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED = -2 BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE = -3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> BeginSponsoringFutureReservesResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/bucket_entry.py b/stellar_sdk/xdr/bucket_entry.py index f8f1af40..52fb80ac 100644 --- a/stellar_sdk/xdr/bucket_entry.py +++ b/stellar_sdk/xdr/bucket_entry.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .bucket_entry_type import BucketEntryType -from .bucket_metadata import BucketMetadata from .ledger_entry import LedgerEntry from .ledger_key import LedgerKey - -__all__ = ["BucketEntry"] - - +from .bucket_metadata import BucketMetadata +__all__ = ['BucketEntry'] class BucketEntry: """ XDR Source Code:: @@ -30,7 +30,6 @@ class BucketEntry: BucketMetadata metaEntry; }; """ - def __init__( self, type: BucketEntryType, @@ -42,7 +41,6 @@ def __init__( self.live_entry = live_entry self.dead_entry = dead_entry self.meta_entry = meta_entry - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == BucketEntryType.LIVEENTRY: @@ -65,7 +63,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("meta_entry should not be None.") self.meta_entry.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> BucketEntry: type = BucketEntryType.unpack(unpacker) @@ -82,7 +79,6 @@ def unpack(cls, unpacker: Unpacker) -> BucketEntry: meta_entry = BucketMetadata.unpack(unpacker) return cls(type=type, meta_entry=meta_entry) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -101,37 +97,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BucketEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.live_entry, - self.dead_entry, - self.meta_entry, - ) - ) - + return hash((self.type, self.live_entry, self.dead_entry, self.meta_entry,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.live_entry == other.live_entry - and self.dead_entry == other.dead_entry - and self.meta_entry == other.meta_entry - ) - + return self.type== other.type and self.live_entry== other.live_entry and self.dead_entry== other.dead_entry and self.meta_entry== other.meta_entry def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"live_entry={self.live_entry}" - ) if self.live_entry is not None else None - out.append( - f"dead_entry={self.dead_entry}" - ) if self.dead_entry is not None else None - out.append( - f"meta_entry={self.meta_entry}" - ) if self.meta_entry is not None else None + out.append(f'type={self.type}') + out.append(f'live_entry={self.live_entry}') if self.live_entry is not None else None + out.append(f'dead_entry={self.dead_entry}') if self.dead_entry is not None else None + out.append(f'meta_entry={self.meta_entry}') if self.meta_entry is not None else None return f"" diff --git a/stellar_sdk/xdr/bucket_entry_type.py b/stellar_sdk/xdr/bucket_entry_type.py index 63d1507a..799121a4 100644 --- a/stellar_sdk/xdr/bucket_entry_type.py +++ b/stellar_sdk/xdr/bucket_entry_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["BucketEntryType"] - - +__all__ = ['BucketEntryType'] class BucketEntryType(IntEnum): """ XDR Source Code:: @@ -24,12 +24,10 @@ class BucketEntryType(IntEnum): INITENTRY = 2 // At-and-after protocol 11: only created. }; """ - METAENTRY = -1 LIVEENTRY = 0 DEADENTRY = 1 INITENTRY = 2 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -37,7 +35,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> BucketEntryType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/bucket_metadata.py b/stellar_sdk/xdr/bucket_metadata.py index a3a00431..bafb8fbe 100644 --- a/stellar_sdk/xdr/bucket_metadata.py +++ b/stellar_sdk/xdr/bucket_metadata.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .bucket_metadata_ext import BucketMetadataExt from .uint32 import Uint32 - -__all__ = ["BucketMetadata"] - - +from .bucket_metadata_ext import BucketMetadataExt +__all__ = ['BucketMetadata'] class BucketMetadata: """ XDR Source Code:: @@ -30,7 +30,6 @@ class BucketMetadata: ext; }; """ - def __init__( self, ledger_version: Uint32, @@ -38,11 +37,9 @@ def __init__( ) -> None: self.ledger_version = ledger_version self.ext = ext - def pack(self, packer: Packer) -> None: self.ledger_version.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> BucketMetadata: ledger_version = Uint32.unpack(unpacker) @@ -51,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> BucketMetadata: ledger_version=ledger_version, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -70,23 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BucketMetadata: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_version, - self.ext, - ) - ) - + return hash((self.ledger_version, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.ledger_version == other.ledger_version and self.ext == other.ext - + return self.ledger_version== other.ledger_version and self.ext== other.ext def __str__(self): out = [ - f"ledger_version={self.ledger_version}", - f"ext={self.ext}", + f'ledger_version={self.ledger_version}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/bucket_metadata_ext.py b/stellar_sdk/xdr/bucket_metadata_ext.py index c102c532..5204efcf 100644 --- a/stellar_sdk/xdr/bucket_metadata_ext.py +++ b/stellar_sdk/xdr/bucket_metadata_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["BucketMetadataExt"] - - +__all__ = ['BucketMetadataExt'] class BucketMetadataExt: """ XDR Source Code:: @@ -21,25 +20,21 @@ class BucketMetadataExt: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> BucketMetadataExt: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BucketMetadataExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/bump_footprint_expiration_op.py b/stellar_sdk/xdr/bump_footprint_expiration_op.py index b3c48ef1..7b33d382 100644 --- a/stellar_sdk/xdr/bump_footprint_expiration_op.py +++ b/stellar_sdk/xdr/bump_footprint_expiration_op.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .extension_point import ExtensionPoint from .uint32 import Uint32 - -__all__ = ["BumpFootprintExpirationOp"] - - +__all__ = ['BumpFootprintExpirationOp'] class BumpFootprintExpirationOp: """ XDR Source Code:: @@ -22,7 +22,6 @@ class BumpFootprintExpirationOp: uint32 ledgersToExpire; }; """ - def __init__( self, ext: ExtensionPoint, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.ext = ext self.ledgers_to_expire = ledgers_to_expire - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.ledgers_to_expire.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> BumpFootprintExpirationOp: ext = ExtensionPoint.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> BumpFootprintExpirationOp: ext=ext, ledgers_to_expire=ledgers_to_expire, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,25 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BumpFootprintExpirationOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.ledgers_to_expire, - ) - ) - + return hash((self.ext, self.ledgers_to_expire,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext and self.ledgers_to_expire == other.ledgers_to_expire - ) - + return self.ext== other.ext and self.ledgers_to_expire== other.ledgers_to_expire def __str__(self): out = [ - f"ext={self.ext}", - f"ledgers_to_expire={self.ledgers_to_expire}", + f'ext={self.ext}', + f'ledgers_to_expire={self.ledgers_to_expire}', ] return f"" diff --git a/stellar_sdk/xdr/bump_footprint_expiration_result.py b/stellar_sdk/xdr/bump_footprint_expiration_result.py index 1606bbd9..09cb122a 100644 --- a/stellar_sdk/xdr/bump_footprint_expiration_result.py +++ b/stellar_sdk/xdr/bump_footprint_expiration_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .bump_footprint_expiration_result_code import BumpFootprintExpirationResultCode - -__all__ = ["BumpFootprintExpirationResult"] - - +__all__ = ['BumpFootprintExpirationResult'] class BumpFootprintExpirationResult: """ XDR Source Code:: @@ -25,58 +25,33 @@ class BumpFootprintExpirationResult: void; }; """ - def __init__( self, code: BumpFootprintExpirationResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) - if ( - self.code - == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_SUCCESS - ): + if self.code == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_SUCCESS: return - if ( - self.code - == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_MALFORMED - ): + if self.code == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_MALFORMED: return - if ( - self.code - == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED - ): + if self.code == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: return - if ( - self.code - == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE - ): + if self.code == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: return - @classmethod def unpack(cls, unpacker: Unpacker) -> BumpFootprintExpirationResult: code = BumpFootprintExpirationResultCode.unpack(unpacker) if code == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_SUCCESS: return cls(code=code) - if ( - code - == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_MALFORMED - ): + if code == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_MALFORMED: return cls(code=code) - if ( - code - == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED - ): + if code == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: return cls(code=code) - if ( - code - == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE - ): + if code == BumpFootprintExpirationResultCode.BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -95,16 +70,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BumpFootprintExpirationResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/bump_footprint_expiration_result_code.py b/stellar_sdk/xdr/bump_footprint_expiration_result_code.py index 52330e97..3b4112ca 100644 --- a/stellar_sdk/xdr/bump_footprint_expiration_result_code.py +++ b/stellar_sdk/xdr/bump_footprint_expiration_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["BumpFootprintExpirationResultCode"] - - +__all__ = ['BumpFootprintExpirationResultCode'] class BumpFootprintExpirationResultCode(IntEnum): """ XDR Source Code:: @@ -25,12 +25,10 @@ class BumpFootprintExpirationResultCode(IntEnum): BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE = -3 }; """ - BUMP_FOOTPRINT_EXPIRATION_SUCCESS = 0 BUMP_FOOTPRINT_EXPIRATION_MALFORMED = -1 BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED = -2 BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE = -3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> BumpFootprintExpirationResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/bump_sequence_op.py b/stellar_sdk/xdr/bump_sequence_op.py index ea331d5b..ba1dd615 100644 --- a/stellar_sdk/xdr/bump_sequence_op.py +++ b/stellar_sdk/xdr/bump_sequence_op.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sequence_number import SequenceNumber - -__all__ = ["BumpSequenceOp"] - - +__all__ = ['BumpSequenceOp'] class BumpSequenceOp: """ XDR Source Code:: @@ -20,23 +20,19 @@ class BumpSequenceOp: SequenceNumber bumpTo; }; """ - def __init__( self, bump_to: SequenceNumber, ) -> None: self.bump_to = bump_to - def pack(self, packer: Packer) -> None: self.bump_to.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> BumpSequenceOp: bump_to = SequenceNumber.unpack(unpacker) return cls( bump_to=bump_to, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BumpSequenceOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.bump_to,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.bump_to == other.bump_to - + return self.bump_to== other.bump_to def __str__(self): out = [ - f"bump_to={self.bump_to}", + f'bump_to={self.bump_to}', ] return f"" diff --git a/stellar_sdk/xdr/bump_sequence_result.py b/stellar_sdk/xdr/bump_sequence_result.py index 8cbfca83..555cc0d5 100644 --- a/stellar_sdk/xdr/bump_sequence_result.py +++ b/stellar_sdk/xdr/bump_sequence_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .bump_sequence_result_code import BumpSequenceResultCode - -__all__ = ["BumpSequenceResult"] - - +__all__ = ['BumpSequenceResult'] class BumpSequenceResult: """ XDR Source Code:: @@ -23,20 +23,17 @@ class BumpSequenceResult: void; }; """ - def __init__( self, code: BumpSequenceResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == BumpSequenceResultCode.BUMP_SEQUENCE_SUCCESS: return if self.code == BumpSequenceResultCode.BUMP_SEQUENCE_BAD_SEQ: return - @classmethod def unpack(cls, unpacker: Unpacker) -> BumpSequenceResult: code = BumpSequenceResultCode.unpack(unpacker) @@ -45,7 +42,6 @@ def unpack(cls, unpacker: Unpacker) -> BumpSequenceResult: if code == BumpSequenceResultCode.BUMP_SEQUENCE_BAD_SEQ: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -64,16 +60,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> BumpSequenceResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/bump_sequence_result_code.py b/stellar_sdk/xdr/bump_sequence_result_code.py index de1721ec..5246e7b1 100644 --- a/stellar_sdk/xdr/bump_sequence_result_code.py +++ b/stellar_sdk/xdr/bump_sequence_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["BumpSequenceResultCode"] - - +__all__ = ['BumpSequenceResultCode'] class BumpSequenceResultCode(IntEnum): """ XDR Source Code:: @@ -22,10 +22,8 @@ class BumpSequenceResultCode(IntEnum): BUMP_SEQUENCE_BAD_SEQ = -1 // `bumpTo` is not within bounds }; """ - BUMP_SEQUENCE_SUCCESS = 0 BUMP_SEQUENCE_BAD_SEQ = -1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -33,7 +31,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> BumpSequenceResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/change_trust_asset.py b/stellar_sdk/xdr/change_trust_asset.py index 2d964fd8..a86b179a 100644 --- a/stellar_sdk/xdr/change_trust_asset.py +++ b/stellar_sdk/xdr/change_trust_asset.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .asset_type import AssetType from .alpha_num4 import AlphaNum4 from .alpha_num12 import AlphaNum12 -from .asset_type import AssetType from .liquidity_pool_parameters import LiquidityPoolParameters - -__all__ = ["ChangeTrustAsset"] - - +__all__ = ['ChangeTrustAsset'] class ChangeTrustAsset: """ XDR Source Code:: @@ -35,7 +35,6 @@ class ChangeTrustAsset: // add other asset types here in the future }; """ - def __init__( self, type: AssetType, @@ -47,7 +46,6 @@ def __init__( self.alpha_num4 = alpha_num4 self.alpha_num12 = alpha_num12 self.liquidity_pool = liquidity_pool - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == AssetType.ASSET_TYPE_NATIVE: @@ -67,7 +65,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("liquidity_pool should not be None.") self.liquidity_pool.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> ChangeTrustAsset: type = AssetType.unpack(unpacker) @@ -83,7 +80,6 @@ def unpack(cls, unpacker: Unpacker) -> ChangeTrustAsset: liquidity_pool = LiquidityPoolParameters.unpack(unpacker) return cls(type=type, liquidity_pool=liquidity_pool) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,37 +98,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ChangeTrustAsset: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.alpha_num4, - self.alpha_num12, - self.liquidity_pool, - ) - ) - + return hash((self.type, self.alpha_num4, self.alpha_num12, self.liquidity_pool,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.alpha_num4 == other.alpha_num4 - and self.alpha_num12 == other.alpha_num12 - and self.liquidity_pool == other.liquidity_pool - ) - + return self.type== other.type and self.alpha_num4== other.alpha_num4 and self.alpha_num12== other.alpha_num12 and self.liquidity_pool== other.liquidity_pool def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"alpha_num4={self.alpha_num4}" - ) if self.alpha_num4 is not None else None - out.append( - f"alpha_num12={self.alpha_num12}" - ) if self.alpha_num12 is not None else None - out.append( - f"liquidity_pool={self.liquidity_pool}" - ) if self.liquidity_pool is not None else None + out.append(f'type={self.type}') + out.append(f'alpha_num4={self.alpha_num4}') if self.alpha_num4 is not None else None + out.append(f'alpha_num12={self.alpha_num12}') if self.alpha_num12 is not None else None + out.append(f'liquidity_pool={self.liquidity_pool}') if self.liquidity_pool is not None else None return f"" diff --git a/stellar_sdk/xdr/change_trust_op.py b/stellar_sdk/xdr/change_trust_op.py index 21f4cd35..f59dcda3 100644 --- a/stellar_sdk/xdr/change_trust_op.py +++ b/stellar_sdk/xdr/change_trust_op.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .change_trust_asset import ChangeTrustAsset from .int64 import Int64 - -__all__ = ["ChangeTrustOp"] - - +__all__ = ['ChangeTrustOp'] class ChangeTrustOp: """ XDR Source Code:: @@ -24,7 +24,6 @@ class ChangeTrustOp: int64 limit; }; """ - def __init__( self, line: ChangeTrustAsset, @@ -32,11 +31,9 @@ def __init__( ) -> None: self.line = line self.limit = limit - def pack(self, packer: Packer) -> None: self.line.pack(packer) self.limit.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ChangeTrustOp: line = ChangeTrustAsset.unpack(unpacker) @@ -45,7 +42,6 @@ def unpack(cls, unpacker: Unpacker) -> ChangeTrustOp: line=line, limit=limit, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -64,23 +60,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ChangeTrustOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.line, - self.limit, - ) - ) - + return hash((self.line, self.limit,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.line == other.line and self.limit == other.limit - + return self.line== other.line and self.limit== other.limit def __str__(self): out = [ - f"line={self.line}", - f"limit={self.limit}", + f'line={self.line}', + f'limit={self.limit}', ] return f"" diff --git a/stellar_sdk/xdr/change_trust_result.py b/stellar_sdk/xdr/change_trust_result.py index be598391..64bdf430 100644 --- a/stellar_sdk/xdr/change_trust_result.py +++ b/stellar_sdk/xdr/change_trust_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .change_trust_result_code import ChangeTrustResultCode - -__all__ = ["ChangeTrustResult"] - - +__all__ = ['ChangeTrustResult'] class ChangeTrustResult: """ XDR Source Code:: @@ -30,13 +30,11 @@ class ChangeTrustResult: void; }; """ - def __init__( self, code: ChangeTrustResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == ChangeTrustResultCode.CHANGE_TRUST_SUCCESS: @@ -55,12 +53,8 @@ def pack(self, packer: Packer) -> None: return if self.code == ChangeTrustResultCode.CHANGE_TRUST_CANNOT_DELETE: return - if ( - self.code - == ChangeTrustResultCode.CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES - ): + if self.code == ChangeTrustResultCode.CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ChangeTrustResult: code = ChangeTrustResultCode.unpack(unpacker) @@ -83,7 +77,6 @@ def unpack(cls, unpacker: Unpacker) -> ChangeTrustResult: if code == ChangeTrustResultCode.CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,16 +95,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ChangeTrustResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/change_trust_result_code.py b/stellar_sdk/xdr/change_trust_result_code.py index fe9c2646..6a67dd1a 100644 --- a/stellar_sdk/xdr/change_trust_result_code.py +++ b/stellar_sdk/xdr/change_trust_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ChangeTrustResultCode"] - - +__all__ = ['ChangeTrustResultCode'] class ChangeTrustResultCode(IntEnum): """ XDR Source Code:: @@ -33,7 +33,6 @@ class ChangeTrustResultCode(IntEnum): -8 // Asset trustline is deauthorized }; """ - CHANGE_TRUST_SUCCESS = 0 CHANGE_TRUST_MALFORMED = -1 CHANGE_TRUST_NO_ISSUER = -2 @@ -43,7 +42,6 @@ class ChangeTrustResultCode(IntEnum): CHANGE_TRUST_TRUST_LINE_MISSING = -6 CHANGE_TRUST_CANNOT_DELETE = -7 CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES = -8 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -51,7 +49,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ChangeTrustResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/claim_atom.py b/stellar_sdk/xdr/claim_atom.py index df865d63..d3c55b65 100644 --- a/stellar_sdk/xdr/claim_atom.py +++ b/stellar_sdk/xdr/claim_atom.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claim_atom_type import ClaimAtomType -from .claim_liquidity_atom import ClaimLiquidityAtom -from .claim_offer_atom import ClaimOfferAtom from .claim_offer_atom_v0 import ClaimOfferAtomV0 - -__all__ = ["ClaimAtom"] - - +from .claim_offer_atom import ClaimOfferAtom +from .claim_liquidity_atom import ClaimLiquidityAtom +__all__ = ['ClaimAtom'] class ClaimAtom: """ XDR Source Code:: @@ -28,7 +28,6 @@ class ClaimAtom: ClaimLiquidityAtom liquidityPool; }; """ - def __init__( self, type: ClaimAtomType, @@ -40,7 +39,6 @@ def __init__( self.v0 = v0 self.order_book = order_book self.liquidity_pool = liquidity_pool - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == ClaimAtomType.CLAIM_ATOM_TYPE_V0: @@ -58,7 +56,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("liquidity_pool should not be None.") self.liquidity_pool.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimAtom: type = ClaimAtomType.unpack(unpacker) @@ -72,7 +69,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimAtom: liquidity_pool = ClaimLiquidityAtom.unpack(unpacker) return cls(type=type, liquidity_pool=liquidity_pool) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -91,35 +87,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimAtom: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.v0, - self.order_book, - self.liquidity_pool, - ) - ) - + return hash((self.type, self.v0, self.order_book, self.liquidity_pool,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.v0 == other.v0 - and self.order_book == other.order_book - and self.liquidity_pool == other.liquidity_pool - ) - + return self.type== other.type and self.v0== other.v0 and self.order_book== other.order_book and self.liquidity_pool== other.liquidity_pool def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"v0={self.v0}") if self.v0 is not None else None - out.append( - f"order_book={self.order_book}" - ) if self.order_book is not None else None - out.append( - f"liquidity_pool={self.liquidity_pool}" - ) if self.liquidity_pool is not None else None + out.append(f'type={self.type}') + out.append(f'v0={self.v0}') if self.v0 is not None else None + out.append(f'order_book={self.order_book}') if self.order_book is not None else None + out.append(f'liquidity_pool={self.liquidity_pool}') if self.liquidity_pool is not None else None return f"" diff --git a/stellar_sdk/xdr/claim_atom_type.py b/stellar_sdk/xdr/claim_atom_type.py index d8ff4cd1..aa839d9a 100644 --- a/stellar_sdk/xdr/claim_atom_type.py +++ b/stellar_sdk/xdr/claim_atom_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ClaimAtomType"] - - +__all__ = ['ClaimAtomType'] class ClaimAtomType(IntEnum): """ XDR Source Code:: @@ -21,11 +21,9 @@ class ClaimAtomType(IntEnum): CLAIM_ATOM_TYPE_LIQUIDITY_POOL = 2 }; """ - CLAIM_ATOM_TYPE_V0 = 0 CLAIM_ATOM_TYPE_ORDER_BOOK = 1 CLAIM_ATOM_TYPE_LIQUIDITY_POOL = 2 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -33,7 +31,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ClaimAtomType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/claim_claimable_balance_op.py b/stellar_sdk/xdr/claim_claimable_balance_op.py index b624af65..3129f415 100644 --- a/stellar_sdk/xdr/claim_claimable_balance_op.py +++ b/stellar_sdk/xdr/claim_claimable_balance_op.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claimable_balance_id import ClaimableBalanceID - -__all__ = ["ClaimClaimableBalanceOp"] - - +__all__ = ['ClaimClaimableBalanceOp'] class ClaimClaimableBalanceOp: """ XDR Source Code:: @@ -20,23 +20,19 @@ class ClaimClaimableBalanceOp: ClaimableBalanceID balanceID; }; """ - def __init__( self, balance_id: ClaimableBalanceID, ) -> None: self.balance_id = balance_id - def pack(self, packer: Packer) -> None: self.balance_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimClaimableBalanceOp: balance_id = ClaimableBalanceID.unpack(unpacker) return cls( balance_id=balance_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimClaimableBalanceOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.balance_id,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.balance_id == other.balance_id - + return self.balance_id== other.balance_id def __str__(self): out = [ - f"balance_id={self.balance_id}", + f'balance_id={self.balance_id}', ] return f"" diff --git a/stellar_sdk/xdr/claim_claimable_balance_result.py b/stellar_sdk/xdr/claim_claimable_balance_result.py index 38085c6f..fa02726c 100644 --- a/stellar_sdk/xdr/claim_claimable_balance_result.py +++ b/stellar_sdk/xdr/claim_claimable_balance_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claim_claimable_balance_result_code import ClaimClaimableBalanceResultCode - -__all__ = ["ClaimClaimableBalanceResult"] - - +__all__ = ['ClaimClaimableBalanceResult'] class ClaimClaimableBalanceResult: """ XDR Source Code:: @@ -27,52 +27,31 @@ class ClaimClaimableBalanceResult: void; }; """ - def __init__( self, code: ClaimClaimableBalanceResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_SUCCESS: return - if ( - self.code - == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST - ): + if self.code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST: return - if ( - self.code - == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM - ): + if self.code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM: return - if ( - self.code - == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_LINE_FULL - ): + if self.code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_LINE_FULL: return - if ( - self.code - == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_NO_TRUST - ): + if self.code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_NO_TRUST: return - if ( - self.code - == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED - ): + if self.code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimClaimableBalanceResult: code = ClaimClaimableBalanceResultCode.unpack(unpacker) if code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_SUCCESS: return cls(code=code) - if ( - code - == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST - ): + if code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST: return cls(code=code) if code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM: return cls(code=code) @@ -80,13 +59,9 @@ def unpack(cls, unpacker: Unpacker) -> ClaimClaimableBalanceResult: return cls(code=code) if code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_NO_TRUST: return cls(code=code) - if ( - code - == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED - ): + if code == ClaimClaimableBalanceResultCode.CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -105,16 +80,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimClaimableBalanceResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/claim_claimable_balance_result_code.py b/stellar_sdk/xdr/claim_claimable_balance_result_code.py index 7627d026..75598911 100644 --- a/stellar_sdk/xdr/claim_claimable_balance_result_code.py +++ b/stellar_sdk/xdr/claim_claimable_balance_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ClaimClaimableBalanceResultCode"] - - +__all__ = ['ClaimClaimableBalanceResultCode'] class ClaimClaimableBalanceResultCode(IntEnum): """ XDR Source Code:: @@ -24,14 +24,12 @@ class ClaimClaimableBalanceResultCode(IntEnum): CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED = -5 }; """ - CLAIM_CLAIMABLE_BALANCE_SUCCESS = 0 CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST = -1 CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM = -2 CLAIM_CLAIMABLE_BALANCE_LINE_FULL = -3 CLAIM_CLAIMABLE_BALANCE_NO_TRUST = -4 CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED = -5 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -39,7 +37,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ClaimClaimableBalanceResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/claim_liquidity_atom.py b/stellar_sdk/xdr/claim_liquidity_atom.py index 26649dc7..3a1b536c 100644 --- a/stellar_sdk/xdr/claim_liquidity_atom.py +++ b/stellar_sdk/xdr/claim_liquidity_atom.py @@ -3,16 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .pool_id import PoolID from .asset import Asset from .int64 import Int64 -from .pool_id import PoolID - -__all__ = ["ClaimLiquidityAtom"] - - +from .asset import Asset +from .int64 import Int64 +__all__ = ['ClaimLiquidityAtom'] class ClaimLiquidityAtom: """ XDR Source Code:: @@ -30,7 +32,6 @@ class ClaimLiquidityAtom: int64 amountBought; }; """ - def __init__( self, liquidity_pool_id: PoolID, @@ -44,14 +45,12 @@ def __init__( self.amount_sold = amount_sold self.asset_bought = asset_bought self.amount_bought = amount_bought - def pack(self, packer: Packer) -> None: self.liquidity_pool_id.pack(packer) self.asset_sold.pack(packer) self.amount_sold.pack(packer) self.asset_bought.pack(packer) self.amount_bought.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimLiquidityAtom: liquidity_pool_id = PoolID.unpack(unpacker) @@ -66,7 +65,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimLiquidityAtom: asset_bought=asset_bought, amount_bought=amount_bought, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -85,35 +83,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimLiquidityAtom: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.liquidity_pool_id, - self.asset_sold, - self.amount_sold, - self.asset_bought, - self.amount_bought, - ) - ) - + return hash((self.liquidity_pool_id, self.asset_sold, self.amount_sold, self.asset_bought, self.amount_bought,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.liquidity_pool_id == other.liquidity_pool_id - and self.asset_sold == other.asset_sold - and self.amount_sold == other.amount_sold - and self.asset_bought == other.asset_bought - and self.amount_bought == other.amount_bought - ) - + return self.liquidity_pool_id== other.liquidity_pool_id and self.asset_sold== other.asset_sold and self.amount_sold== other.amount_sold and self.asset_bought== other.asset_bought and self.amount_bought== other.amount_bought def __str__(self): out = [ - f"liquidity_pool_id={self.liquidity_pool_id}", - f"asset_sold={self.asset_sold}", - f"amount_sold={self.amount_sold}", - f"asset_bought={self.asset_bought}", - f"amount_bought={self.amount_bought}", + f'liquidity_pool_id={self.liquidity_pool_id}', + f'asset_sold={self.asset_sold}', + f'amount_sold={self.amount_sold}', + f'asset_bought={self.asset_bought}', + f'amount_bought={self.amount_bought}', ] return f"" diff --git a/stellar_sdk/xdr/claim_offer_atom.py b/stellar_sdk/xdr/claim_offer_atom.py index 72cabc81..4050725b 100644 --- a/stellar_sdk/xdr/claim_offer_atom.py +++ b/stellar_sdk/xdr/claim_offer_atom.py @@ -3,16 +3,19 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID +from .int64 import Int64 from .asset import Asset from .int64 import Int64 - -__all__ = ["ClaimOfferAtom"] - - +from .asset import Asset +from .int64 import Int64 +__all__ = ['ClaimOfferAtom'] class ClaimOfferAtom: """ XDR Source Code:: @@ -32,7 +35,6 @@ class ClaimOfferAtom: int64 amountBought; }; """ - def __init__( self, seller_id: AccountID, @@ -48,7 +50,6 @@ def __init__( self.amount_sold = amount_sold self.asset_bought = asset_bought self.amount_bought = amount_bought - def pack(self, packer: Packer) -> None: self.seller_id.pack(packer) self.offer_id.pack(packer) @@ -56,7 +57,6 @@ def pack(self, packer: Packer) -> None: self.amount_sold.pack(packer) self.asset_bought.pack(packer) self.amount_bought.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimOfferAtom: seller_id = AccountID.unpack(unpacker) @@ -73,7 +73,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimOfferAtom: asset_bought=asset_bought, amount_bought=amount_bought, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -92,38 +91,19 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimOfferAtom: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.seller_id, - self.offer_id, - self.asset_sold, - self.amount_sold, - self.asset_bought, - self.amount_bought, - ) - ) - + return hash((self.seller_id, self.offer_id, self.asset_sold, self.amount_sold, self.asset_bought, self.amount_bought,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.seller_id == other.seller_id - and self.offer_id == other.offer_id - and self.asset_sold == other.asset_sold - and self.amount_sold == other.amount_sold - and self.asset_bought == other.asset_bought - and self.amount_bought == other.amount_bought - ) - + return self.seller_id== other.seller_id and self.offer_id== other.offer_id and self.asset_sold== other.asset_sold and self.amount_sold== other.amount_sold and self.asset_bought== other.asset_bought and self.amount_bought== other.amount_bought def __str__(self): out = [ - f"seller_id={self.seller_id}", - f"offer_id={self.offer_id}", - f"asset_sold={self.asset_sold}", - f"amount_sold={self.amount_sold}", - f"asset_bought={self.asset_bought}", - f"amount_bought={self.amount_bought}", + f'seller_id={self.seller_id}', + f'offer_id={self.offer_id}', + f'asset_sold={self.asset_sold}', + f'amount_sold={self.amount_sold}', + f'asset_bought={self.asset_bought}', + f'amount_bought={self.amount_bought}', ] return f"" diff --git a/stellar_sdk/xdr/claim_offer_atom_v0.py b/stellar_sdk/xdr/claim_offer_atom_v0.py index ce6efbb4..54507cc2 100644 --- a/stellar_sdk/xdr/claim_offer_atom_v0.py +++ b/stellar_sdk/xdr/claim_offer_atom_v0.py @@ -3,16 +3,19 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .uint256 import Uint256 +from .int64 import Int64 from .asset import Asset from .int64 import Int64 -from .uint256 import Uint256 - -__all__ = ["ClaimOfferAtomV0"] - - +from .asset import Asset +from .int64 import Int64 +__all__ = ['ClaimOfferAtomV0'] class ClaimOfferAtomV0: """ XDR Source Code:: @@ -32,7 +35,6 @@ class ClaimOfferAtomV0: int64 amountBought; }; """ - def __init__( self, seller_ed25519: Uint256, @@ -48,7 +50,6 @@ def __init__( self.amount_sold = amount_sold self.asset_bought = asset_bought self.amount_bought = amount_bought - def pack(self, packer: Packer) -> None: self.seller_ed25519.pack(packer) self.offer_id.pack(packer) @@ -56,7 +57,6 @@ def pack(self, packer: Packer) -> None: self.amount_sold.pack(packer) self.asset_bought.pack(packer) self.amount_bought.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimOfferAtomV0: seller_ed25519 = Uint256.unpack(unpacker) @@ -73,7 +73,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimOfferAtomV0: asset_bought=asset_bought, amount_bought=amount_bought, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -92,38 +91,19 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimOfferAtomV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.seller_ed25519, - self.offer_id, - self.asset_sold, - self.amount_sold, - self.asset_bought, - self.amount_bought, - ) - ) - + return hash((self.seller_ed25519, self.offer_id, self.asset_sold, self.amount_sold, self.asset_bought, self.amount_bought,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.seller_ed25519 == other.seller_ed25519 - and self.offer_id == other.offer_id - and self.asset_sold == other.asset_sold - and self.amount_sold == other.amount_sold - and self.asset_bought == other.asset_bought - and self.amount_bought == other.amount_bought - ) - + return self.seller_ed25519== other.seller_ed25519 and self.offer_id== other.offer_id and self.asset_sold== other.asset_sold and self.amount_sold== other.amount_sold and self.asset_bought== other.asset_bought and self.amount_bought== other.amount_bought def __str__(self): out = [ - f"seller_ed25519={self.seller_ed25519}", - f"offer_id={self.offer_id}", - f"asset_sold={self.asset_sold}", - f"amount_sold={self.amount_sold}", - f"asset_bought={self.asset_bought}", - f"amount_bought={self.amount_bought}", + f'seller_ed25519={self.seller_ed25519}', + f'offer_id={self.offer_id}', + f'asset_sold={self.asset_sold}', + f'amount_sold={self.amount_sold}', + f'asset_bought={self.asset_bought}', + f'amount_bought={self.amount_bought}', ] return f"" diff --git a/stellar_sdk/xdr/claim_predicate.py b/stellar_sdk/xdr/claim_predicate.py index 1e319397..88057cbd 100644 --- a/stellar_sdk/xdr/claim_predicate.py +++ b/stellar_sdk/xdr/claim_predicate.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 -from typing import List, Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claim_predicate_type import ClaimPredicateType from .int64 import Int64 - -__all__ = ["ClaimPredicate"] - - +from .int64 import Int64 +__all__ = ['ClaimPredicate'] class ClaimPredicate: """ XDR Source Code:: @@ -34,7 +34,6 @@ class ClaimPredicate: // ClaimableBalanceEntry was created }; """ - def __init__( self, type: ClaimPredicateType, @@ -46,21 +45,16 @@ def __init__( ) -> None: _expect_max_length = 2 if and_predicates and len(and_predicates) > _expect_max_length: - raise ValueError( - f"The maximum length of `and_predicates` should be {_expect_max_length}, but got {len(and_predicates)}." - ) + raise ValueError(f"The maximum length of `and_predicates` should be {_expect_max_length}, but got {len(and_predicates)}.") _expect_max_length = 2 if or_predicates and len(or_predicates) > _expect_max_length: - raise ValueError( - f"The maximum length of `or_predicates` should be {_expect_max_length}, but got {len(or_predicates)}." - ) + raise ValueError(f"The maximum length of `or_predicates` should be {_expect_max_length}, but got {len(or_predicates)}.") self.type = type self.and_predicates = and_predicates self.or_predicates = or_predicates self.not_predicate = not_predicate self.abs_before = abs_before self.rel_before = rel_before - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == ClaimPredicateType.CLAIM_PREDICATE_UNCONDITIONAL: @@ -98,7 +92,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("rel_before should not be None.") self.rel_before.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimPredicate: type = ClaimPredicateType.unpack(unpacker) @@ -117,9 +110,7 @@ def unpack(cls, unpacker: Unpacker) -> ClaimPredicate: or_predicates.append(ClaimPredicate.unpack(unpacker)) return cls(type=type, or_predicates=or_predicates) if type == ClaimPredicateType.CLAIM_PREDICATE_NOT: - not_predicate = ( - ClaimPredicate.unpack(unpacker) if unpacker.unpack_uint() else None - ) + not_predicate = ClaimPredicate.unpack(unpacker) if unpacker.unpack_uint() else None return cls(type=type, not_predicate=not_predicate) if type == ClaimPredicateType.CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME: abs_before = Int64.unpack(unpacker) @@ -128,7 +119,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimPredicate: rel_before = Int64.unpack(unpacker) return cls(type=type, rel_before=rel_before) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -147,47 +137,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimPredicate: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.and_predicates, - self.or_predicates, - self.not_predicate, - self.abs_before, - self.rel_before, - ) - ) - + return hash((self.type, self.and_predicates, self.or_predicates, self.not_predicate, self.abs_before, self.rel_before,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.and_predicates == other.and_predicates - and self.or_predicates == other.or_predicates - and self.not_predicate == other.not_predicate - and self.abs_before == other.abs_before - and self.rel_before == other.rel_before - ) - + return self.type== other.type and self.and_predicates== other.and_predicates and self.or_predicates== other.or_predicates and self.not_predicate== other.not_predicate and self.abs_before== other.abs_before and self.rel_before== other.rel_before def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"and_predicates={self.and_predicates}" - ) if self.and_predicates is not None else None - out.append( - f"or_predicates={self.or_predicates}" - ) if self.or_predicates is not None else None - out.append( - f"not_predicate={self.not_predicate}" - ) if self.not_predicate is not None else None - out.append( - f"abs_before={self.abs_before}" - ) if self.abs_before is not None else None - out.append( - f"rel_before={self.rel_before}" - ) if self.rel_before is not None else None + out.append(f'type={self.type}') + out.append(f'and_predicates={self.and_predicates}') if self.and_predicates is not None else None + out.append(f'or_predicates={self.or_predicates}') if self.or_predicates is not None else None + out.append(f'not_predicate={self.not_predicate}') if self.not_predicate is not None else None + out.append(f'abs_before={self.abs_before}') if self.abs_before is not None else None + out.append(f'rel_before={self.rel_before}') if self.rel_before is not None else None return f"" diff --git a/stellar_sdk/xdr/claim_predicate_type.py b/stellar_sdk/xdr/claim_predicate_type.py index 6e4bf25b..a41ab839 100644 --- a/stellar_sdk/xdr/claim_predicate_type.py +++ b/stellar_sdk/xdr/claim_predicate_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ClaimPredicateType"] - - +__all__ = ['ClaimPredicateType'] class ClaimPredicateType(IntEnum): """ XDR Source Code:: @@ -24,14 +24,12 @@ class ClaimPredicateType(IntEnum): CLAIM_PREDICATE_BEFORE_RELATIVE_TIME = 5 }; """ - CLAIM_PREDICATE_UNCONDITIONAL = 0 CLAIM_PREDICATE_AND = 1 CLAIM_PREDICATE_OR = 2 CLAIM_PREDICATE_NOT = 3 CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME = 4 CLAIM_PREDICATE_BEFORE_RELATIVE_TIME = 5 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -39,7 +37,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ClaimPredicateType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/claimable_balance_entry.py b/stellar_sdk/xdr/claimable_balance_entry.py index 6897e14f..44da1bb4 100644 --- a/stellar_sdk/xdr/claimable_balance_entry.py +++ b/stellar_sdk/xdr/claimable_balance_entry.py @@ -3,19 +3,18 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .asset import Asset -from .claimable_balance_entry_ext import ClaimableBalanceEntryExt from .claimable_balance_id import ClaimableBalanceID from .claimant import Claimant +from .asset import Asset from .int64 import Int64 - -__all__ = ["ClaimableBalanceEntry"] - - +from .claimable_balance_entry_ext import ClaimableBalanceEntryExt +__all__ = ['ClaimableBalanceEntry'] class ClaimableBalanceEntry: """ XDR Source Code:: @@ -45,7 +44,6 @@ class ClaimableBalanceEntry: ext; }; """ - def __init__( self, balance_id: ClaimableBalanceID, @@ -56,15 +54,12 @@ def __init__( ) -> None: _expect_max_length = 10 if claimants and len(claimants) > _expect_max_length: - raise ValueError( - f"The maximum length of `claimants` should be {_expect_max_length}, but got {len(claimants)}." - ) + raise ValueError(f"The maximum length of `claimants` should be {_expect_max_length}, but got {len(claimants)}.") self.balance_id = balance_id self.claimants = claimants self.asset = asset self.amount = amount self.ext = ext - def pack(self, packer: Packer) -> None: self.balance_id.pack(packer) packer.pack_uint(len(self.claimants)) @@ -73,7 +68,6 @@ def pack(self, packer: Packer) -> None: self.asset.pack(packer) self.amount.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceEntry: balance_id = ClaimableBalanceID.unpack(unpacker) @@ -91,7 +85,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceEntry: amount=amount, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -110,35 +103,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimableBalanceEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.balance_id, - self.claimants, - self.asset, - self.amount, - self.ext, - ) - ) - + return hash((self.balance_id, self.claimants, self.asset, self.amount, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.balance_id == other.balance_id - and self.claimants == other.claimants - and self.asset == other.asset - and self.amount == other.amount - and self.ext == other.ext - ) - + return self.balance_id== other.balance_id and self.claimants== other.claimants and self.asset== other.asset and self.amount== other.amount and self.ext== other.ext def __str__(self): out = [ - f"balance_id={self.balance_id}", - f"claimants={self.claimants}", - f"asset={self.asset}", - f"amount={self.amount}", - f"ext={self.ext}", + f'balance_id={self.balance_id}', + f'claimants={self.claimants}', + f'asset={self.asset}', + f'amount={self.amount}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/claimable_balance_entry_ext.py b/stellar_sdk/xdr/claimable_balance_entry_ext.py index f11d0556..663d4789 100644 --- a/stellar_sdk/xdr/claimable_balance_entry_ext.py +++ b/stellar_sdk/xdr/claimable_balance_entry_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .claimable_balance_entry_extension_v1 import ClaimableBalanceEntryExtensionV1 - -__all__ = ["ClaimableBalanceEntryExt"] - - +__all__ = ['ClaimableBalanceEntryExt'] class ClaimableBalanceEntryExt: """ XDR Source Code:: @@ -24,7 +23,6 @@ class ClaimableBalanceEntryExt: ClaimableBalanceEntryExtensionV1 v1; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.v1 = v1 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v1 should not be None.") self.v1.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceEntryExt: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceEntryExt: v1 = ClaimableBalanceEntryExtensionV1.unpack(unpacker) return cls(v=v, v1=v1) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,22 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimableBalanceEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v1, - ) - ) - + return hash((self.v, self.v1,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v1 == other.v1 - + return self.v== other.v and self.v1== other.v1 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v1={self.v1}") if self.v1 is not None else None + out.append(f'v={self.v}') + out.append(f'v1={self.v1}') if self.v1 is not None else None return f"" diff --git a/stellar_sdk/xdr/claimable_balance_entry_extension_v1.py b/stellar_sdk/xdr/claimable_balance_entry_extension_v1.py index 7f79abbd..5cfdcbf9 100644 --- a/stellar_sdk/xdr/claimable_balance_entry_extension_v1.py +++ b/stellar_sdk/xdr/claimable_balance_entry_extension_v1.py @@ -3,17 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .claimable_balance_entry_extension_v1_ext import ( - ClaimableBalanceEntryExtensionV1Ext, -) +from .claimable_balance_entry_extension_v1_ext import ClaimableBalanceEntryExtensionV1Ext from .uint32 import Uint32 - -__all__ = ["ClaimableBalanceEntryExtensionV1"] - - +__all__ = ['ClaimableBalanceEntryExtensionV1'] class ClaimableBalanceEntryExtensionV1: """ XDR Source Code:: @@ -30,7 +28,6 @@ class ClaimableBalanceEntryExtensionV1: uint32 flags; // see ClaimableBalanceFlags }; """ - def __init__( self, ext: ClaimableBalanceEntryExtensionV1Ext, @@ -38,11 +35,9 @@ def __init__( ) -> None: self.ext = ext self.flags = flags - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.flags.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceEntryExtensionV1: ext = ClaimableBalanceEntryExtensionV1Ext.unpack(unpacker) @@ -51,7 +46,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceEntryExtensionV1: ext=ext, flags=flags, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -70,23 +64,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimableBalanceEntryExtensionV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.flags, - ) - ) - + return hash((self.ext, self.flags,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.ext == other.ext and self.flags == other.flags - + return self.ext== other.ext and self.flags== other.flags def __str__(self): out = [ - f"ext={self.ext}", - f"flags={self.flags}", + f'ext={self.ext}', + f'flags={self.flags}', ] return f"" diff --git a/stellar_sdk/xdr/claimable_balance_entry_extension_v1_ext.py b/stellar_sdk/xdr/claimable_balance_entry_extension_v1_ext.py index f4886533..d2ce1e4b 100644 --- a/stellar_sdk/xdr/claimable_balance_entry_extension_v1_ext.py +++ b/stellar_sdk/xdr/claimable_balance_entry_extension_v1_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["ClaimableBalanceEntryExtensionV1Ext"] - - +__all__ = ['ClaimableBalanceEntryExtensionV1Ext'] class ClaimableBalanceEntryExtensionV1Ext: """ XDR Source Code:: @@ -21,25 +20,21 @@ class ClaimableBalanceEntryExtensionV1Ext: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceEntryExtensionV1Ext: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimableBalanceEntryExtensionV1Ext: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/claimable_balance_flags.py b/stellar_sdk/xdr/claimable_balance_flags.py index 3f03f7d7..5b38ddcf 100644 --- a/stellar_sdk/xdr/claimable_balance_flags.py +++ b/stellar_sdk/xdr/claimable_balance_flags.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ClaimableBalanceFlags"] - - +__all__ = ['ClaimableBalanceFlags'] class ClaimableBalanceFlags(IntEnum): """ XDR Source Code:: @@ -21,9 +21,7 @@ class ClaimableBalanceFlags(IntEnum): CLAIMABLE_BALANCE_CLAWBACK_ENABLED_FLAG = 0x1 }; """ - CLAIMABLE_BALANCE_CLAWBACK_ENABLED_FLAG = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceFlags: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/claimable_balance_id.py b/stellar_sdk/xdr/claimable_balance_id.py index 1ab22c7b..ea27facb 100644 --- a/stellar_sdk/xdr/claimable_balance_id.py +++ b/stellar_sdk/xdr/claimable_balance_id.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claimable_balance_id_type import ClaimableBalanceIDType from .hash import Hash - -__all__ = ["ClaimableBalanceID"] - - +__all__ = ['ClaimableBalanceID'] class ClaimableBalanceID: """ XDR Source Code:: @@ -22,7 +22,6 @@ class ClaimableBalanceID: Hash v0; }; """ - def __init__( self, type: ClaimableBalanceIDType, @@ -30,7 +29,6 @@ def __init__( ) -> None: self.type = type self.v0 = v0 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == ClaimableBalanceIDType.CLAIMABLE_BALANCE_ID_TYPE_V0: @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v0 should not be None.") self.v0.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceID: type = ClaimableBalanceIDType.unpack(unpacker) @@ -46,7 +43,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceID: v0 = Hash.unpack(unpacker) return cls(type=type, v0=v0) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -65,22 +61,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimableBalanceID: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.v0, - ) - ) - + return hash((self.type, self.v0,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.type == other.type and self.v0 == other.v0 - + return self.type== other.type and self.v0== other.v0 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"v0={self.v0}") if self.v0 is not None else None + out.append(f'type={self.type}') + out.append(f'v0={self.v0}') if self.v0 is not None else None return f"" diff --git a/stellar_sdk/xdr/claimable_balance_id_type.py b/stellar_sdk/xdr/claimable_balance_id_type.py index 5cb684ed..fef45461 100644 --- a/stellar_sdk/xdr/claimable_balance_id_type.py +++ b/stellar_sdk/xdr/claimable_balance_id_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ClaimableBalanceIDType"] - - +__all__ = ['ClaimableBalanceIDType'] class ClaimableBalanceIDType(IntEnum): """ XDR Source Code:: @@ -19,9 +19,7 @@ class ClaimableBalanceIDType(IntEnum): CLAIMABLE_BALANCE_ID_TYPE_V0 = 0 }; """ - CLAIMABLE_BALANCE_ID_TYPE_V0 = 0 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -29,7 +27,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ClaimableBalanceIDType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/claimant.py b/stellar_sdk/xdr/claimant.py index ee1bdd12..31f6092a 100644 --- a/stellar_sdk/xdr/claimant.py +++ b/stellar_sdk/xdr/claimant.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claimant_type import ClaimantType from .claimant_v0 import ClaimantV0 - -__all__ = ["Claimant"] - - +__all__ = ['Claimant'] class Claimant: """ XDR Source Code:: @@ -26,7 +26,6 @@ class Claimant: } v0; }; """ - def __init__( self, type: ClaimantType, @@ -34,7 +33,6 @@ def __init__( ) -> None: self.type = type self.v0 = v0 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == ClaimantType.CLAIMANT_TYPE_V0: @@ -42,7 +40,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v0 should not be None.") self.v0.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> Claimant: type = ClaimantType.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> Claimant: v0 = ClaimantV0.unpack(unpacker) return cls(type=type, v0=v0) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,22 +65,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Claimant: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.v0, - ) - ) - + return hash((self.type, self.v0,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.type == other.type and self.v0 == other.v0 - + return self.type== other.type and self.v0== other.v0 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"v0={self.v0}") if self.v0 is not None else None + out.append(f'type={self.type}') + out.append(f'v0={self.v0}') if self.v0 is not None else None return f"" diff --git a/stellar_sdk/xdr/claimant_type.py b/stellar_sdk/xdr/claimant_type.py index f090fd0b..909035b8 100644 --- a/stellar_sdk/xdr/claimant_type.py +++ b/stellar_sdk/xdr/claimant_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ClaimantType"] - - +__all__ = ['ClaimantType'] class ClaimantType(IntEnum): """ XDR Source Code:: @@ -19,9 +19,7 @@ class ClaimantType(IntEnum): CLAIMANT_TYPE_V0 = 0 }; """ - CLAIMANT_TYPE_V0 = 0 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -29,7 +27,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ClaimantType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/claimant_v0.py b/stellar_sdk/xdr/claimant_v0.py index 35fb46b9..0b8b54b2 100644 --- a/stellar_sdk/xdr/claimant_v0.py +++ b/stellar_sdk/xdr/claimant_v0.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .claim_predicate import ClaimPredicate - -__all__ = ["ClaimantV0"] - - +__all__ = ['ClaimantV0'] class ClaimantV0: """ XDR Source Code:: @@ -22,7 +22,6 @@ class ClaimantV0: ClaimPredicate predicate; // Claimable if predicate is true } """ - def __init__( self, destination: AccountID, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.destination = destination self.predicate = predicate - def pack(self, packer: Packer) -> None: self.destination.pack(packer) self.predicate.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClaimantV0: destination = AccountID.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> ClaimantV0: destination=destination, predicate=predicate, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,25 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClaimantV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.destination, - self.predicate, - ) - ) - + return hash((self.destination, self.predicate,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.destination == other.destination and self.predicate == other.predicate - ) - + return self.destination== other.destination and self.predicate== other.predicate def __str__(self): out = [ - f"destination={self.destination}", - f"predicate={self.predicate}", + f'destination={self.destination}', + f'predicate={self.predicate}', ] return f"" diff --git a/stellar_sdk/xdr/clawback_claimable_balance_op.py b/stellar_sdk/xdr/clawback_claimable_balance_op.py index c498628e..b9dbeb55 100644 --- a/stellar_sdk/xdr/clawback_claimable_balance_op.py +++ b/stellar_sdk/xdr/clawback_claimable_balance_op.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claimable_balance_id import ClaimableBalanceID - -__all__ = ["ClawbackClaimableBalanceOp"] - - +__all__ = ['ClawbackClaimableBalanceOp'] class ClawbackClaimableBalanceOp: """ XDR Source Code:: @@ -20,23 +20,19 @@ class ClawbackClaimableBalanceOp: ClaimableBalanceID balanceID; }; """ - def __init__( self, balance_id: ClaimableBalanceID, ) -> None: self.balance_id = balance_id - def pack(self, packer: Packer) -> None: self.balance_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClawbackClaimableBalanceOp: balance_id = ClaimableBalanceID.unpack(unpacker) return cls( balance_id=balance_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClawbackClaimableBalanceOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.balance_id,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.balance_id == other.balance_id - + return self.balance_id== other.balance_id def __str__(self): out = [ - f"balance_id={self.balance_id}", + f'balance_id={self.balance_id}', ] return f"" diff --git a/stellar_sdk/xdr/clawback_claimable_balance_result.py b/stellar_sdk/xdr/clawback_claimable_balance_result.py index accf7b02..317fa0e9 100644 --- a/stellar_sdk/xdr/clawback_claimable_balance_result.py +++ b/stellar_sdk/xdr/clawback_claimable_balance_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .clawback_claimable_balance_result_code import ClawbackClaimableBalanceResultCode - -__all__ = ["ClawbackClaimableBalanceResult"] - - +__all__ = ['ClawbackClaimableBalanceResult'] class ClawbackClaimableBalanceResult: """ XDR Source Code:: @@ -26,61 +26,33 @@ class ClawbackClaimableBalanceResult: void; }; """ - def __init__( self, code: ClawbackClaimableBalanceResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) - if ( - self.code - == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_SUCCESS - ): + if self.code == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_SUCCESS: return - if ( - self.code - == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST - ): + if self.code == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST: return - if ( - self.code - == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER - ): + if self.code == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER: return - if ( - self.code - == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED - ): + if self.code == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ClawbackClaimableBalanceResult: code = ClawbackClaimableBalanceResultCode.unpack(unpacker) - if ( - code - == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_SUCCESS - ): + if code == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_SUCCESS: return cls(code=code) - if ( - code - == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST - ): + if code == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST: return cls(code=code) - if ( - code - == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER - ): + if code == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER: return cls(code=code) - if ( - code - == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED - ): + if code == ClawbackClaimableBalanceResultCode.CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -99,16 +71,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClawbackClaimableBalanceResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/clawback_claimable_balance_result_code.py b/stellar_sdk/xdr/clawback_claimable_balance_result_code.py index 2623575b..ddfe4303 100644 --- a/stellar_sdk/xdr/clawback_claimable_balance_result_code.py +++ b/stellar_sdk/xdr/clawback_claimable_balance_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ClawbackClaimableBalanceResultCode"] - - +__all__ = ['ClawbackClaimableBalanceResultCode'] class ClawbackClaimableBalanceResultCode(IntEnum): """ XDR Source Code:: @@ -25,12 +25,10 @@ class ClawbackClaimableBalanceResultCode(IntEnum): CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED = -3 }; """ - CLAWBACK_CLAIMABLE_BALANCE_SUCCESS = 0 CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST = -1 CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER = -2 CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED = -3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ClawbackClaimableBalanceResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/clawback_op.py b/stellar_sdk/xdr/clawback_op.py index f202878e..b4596542 100644 --- a/stellar_sdk/xdr/clawback_op.py +++ b/stellar_sdk/xdr/clawback_op.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .asset import Asset -from .int64 import Int64 from .muxed_account import MuxedAccount - -__all__ = ["ClawbackOp"] - - +from .int64 import Int64 +__all__ = ['ClawbackOp'] class ClawbackOp: """ XDR Source Code:: @@ -24,7 +24,6 @@ class ClawbackOp: int64 amount; }; """ - def __init__( self, asset: Asset, @@ -34,12 +33,10 @@ def __init__( self.asset = asset self.from_ = from_ self.amount = amount - def pack(self, packer: Packer) -> None: self.asset.pack(packer) self.from_.pack(packer) self.amount.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ClawbackOp: asset = Asset.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> ClawbackOp: from_=from_, amount=amount, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClawbackOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.asset, - self.from_, - self.amount, - ) - ) - + return hash((self.asset, self.from_, self.amount,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.asset == other.asset - and self.from_ == other.from_ - and self.amount == other.amount - ) - + return self.asset== other.asset and self.from_== other.from_ and self.amount== other.amount def __str__(self): out = [ - f"asset={self.asset}", - f"from_={self.from_}", - f"amount={self.amount}", + f'asset={self.asset}', + f'from_={self.from_}', + f'amount={self.amount}', ] return f"" diff --git a/stellar_sdk/xdr/clawback_result.py b/stellar_sdk/xdr/clawback_result.py index 6c447ded..f9033db8 100644 --- a/stellar_sdk/xdr/clawback_result.py +++ b/stellar_sdk/xdr/clawback_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .clawback_result_code import ClawbackResultCode - -__all__ = ["ClawbackResult"] - - +__all__ = ['ClawbackResult'] class ClawbackResult: """ XDR Source Code:: @@ -26,13 +26,11 @@ class ClawbackResult: void; }; """ - def __init__( self, code: ClawbackResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == ClawbackResultCode.CLAWBACK_SUCCESS: @@ -45,7 +43,6 @@ def pack(self, packer: Packer) -> None: return if self.code == ClawbackResultCode.CLAWBACK_UNDERFUNDED: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ClawbackResult: code = ClawbackResultCode.unpack(unpacker) @@ -60,7 +57,6 @@ def unpack(cls, unpacker: Unpacker) -> ClawbackResult: if code == ClawbackResultCode.CLAWBACK_UNDERFUNDED: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -79,16 +75,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ClawbackResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/clawback_result_code.py b/stellar_sdk/xdr/clawback_result_code.py index d5b91689..01b8d744 100644 --- a/stellar_sdk/xdr/clawback_result_code.py +++ b/stellar_sdk/xdr/clawback_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ClawbackResultCode"] - - +__all__ = ['ClawbackResultCode'] class ClawbackResultCode(IntEnum): """ XDR Source Code:: @@ -26,13 +26,11 @@ class ClawbackResultCode(IntEnum): CLAWBACK_UNDERFUNDED = -4 }; """ - CLAWBACK_SUCCESS = 0 CLAWBACK_MALFORMED = -1 CLAWBACK_NOT_CLAWBACK_ENABLED = -2 CLAWBACK_NO_TRUST = -3 CLAWBACK_UNDERFUNDED = -4 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -40,7 +38,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ClawbackResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/config_setting_contract_bandwidth_v0.py b/stellar_sdk/xdr/config_setting_contract_bandwidth_v0.py index 0b907612..be2a6905 100644 --- a/stellar_sdk/xdr/config_setting_contract_bandwidth_v0.py +++ b/stellar_sdk/xdr/config_setting_contract_bandwidth_v0.py @@ -3,15 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .int64 import Int64 from .uint32 import Uint32 - -__all__ = ["ConfigSettingContractBandwidthV0"] - - +from .uint32 import Uint32 +from .int64 import Int64 +__all__ = ['ConfigSettingContractBandwidthV0'] class ConfigSettingContractBandwidthV0: """ XDR Source Code:: @@ -27,7 +28,6 @@ class ConfigSettingContractBandwidthV0: int64 feeTxSize1KB; }; """ - def __init__( self, ledger_max_txs_size_bytes: Uint32, @@ -37,12 +37,10 @@ def __init__( self.ledger_max_txs_size_bytes = ledger_max_txs_size_bytes self.tx_max_size_bytes = tx_max_size_bytes self.fee_tx_size1_kb = fee_tx_size1_kb - def pack(self, packer: Packer) -> None: self.ledger_max_txs_size_bytes.pack(packer) self.tx_max_size_bytes.pack(packer) self.fee_tx_size1_kb.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractBandwidthV0: ledger_max_txs_size_bytes = Uint32.unpack(unpacker) @@ -53,7 +51,6 @@ def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractBandwidthV0: tx_max_size_bytes=tx_max_size_bytes, fee_tx_size1_kb=fee_tx_size1_kb, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -72,29 +69,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ConfigSettingContractBandwidthV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_max_txs_size_bytes, - self.tx_max_size_bytes, - self.fee_tx_size1_kb, - ) - ) - + return hash((self.ledger_max_txs_size_bytes, self.tx_max_size_bytes, self.fee_tx_size1_kb,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_max_txs_size_bytes == other.ledger_max_txs_size_bytes - and self.tx_max_size_bytes == other.tx_max_size_bytes - and self.fee_tx_size1_kb == other.fee_tx_size1_kb - ) - + return self.ledger_max_txs_size_bytes== other.ledger_max_txs_size_bytes and self.tx_max_size_bytes== other.tx_max_size_bytes and self.fee_tx_size1_kb== other.fee_tx_size1_kb def __str__(self): out = [ - f"ledger_max_txs_size_bytes={self.ledger_max_txs_size_bytes}", - f"tx_max_size_bytes={self.tx_max_size_bytes}", - f"fee_tx_size1_kb={self.fee_tx_size1_kb}", + f'ledger_max_txs_size_bytes={self.ledger_max_txs_size_bytes}', + f'tx_max_size_bytes={self.tx_max_size_bytes}', + f'fee_tx_size1_kb={self.fee_tx_size1_kb}', ] return f"" diff --git a/stellar_sdk/xdr/config_setting_contract_compute_v0.py b/stellar_sdk/xdr/config_setting_contract_compute_v0.py index 40c0490c..69a5aef9 100644 --- a/stellar_sdk/xdr/config_setting_contract_compute_v0.py +++ b/stellar_sdk/xdr/config_setting_contract_compute_v0.py @@ -3,15 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .int64 import Int64 +from .int64 import Int64 from .int64 import Int64 from .uint32 import Uint32 - -__all__ = ["ConfigSettingContractComputeV0"] - - +__all__ = ['ConfigSettingContractComputeV0'] class ConfigSettingContractComputeV0: """ XDR Source Code:: @@ -30,7 +32,6 @@ class ConfigSettingContractComputeV0: uint32 txMemoryLimit; }; """ - def __init__( self, ledger_max_instructions: Int64, @@ -42,13 +43,11 @@ def __init__( self.tx_max_instructions = tx_max_instructions self.fee_rate_per_instructions_increment = fee_rate_per_instructions_increment self.tx_memory_limit = tx_memory_limit - def pack(self, packer: Packer) -> None: self.ledger_max_instructions.pack(packer) self.tx_max_instructions.pack(packer) self.fee_rate_per_instructions_increment.pack(packer) self.tx_memory_limit.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractComputeV0: ledger_max_instructions = Int64.unpack(unpacker) @@ -61,7 +60,6 @@ def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractComputeV0: fee_rate_per_instructions_increment=fee_rate_per_instructions_increment, tx_memory_limit=tx_memory_limit, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -80,33 +78,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ConfigSettingContractComputeV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_max_instructions, - self.tx_max_instructions, - self.fee_rate_per_instructions_increment, - self.tx_memory_limit, - ) - ) - + return hash((self.ledger_max_instructions, self.tx_max_instructions, self.fee_rate_per_instructions_increment, self.tx_memory_limit,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_max_instructions == other.ledger_max_instructions - and self.tx_max_instructions == other.tx_max_instructions - and self.fee_rate_per_instructions_increment - == other.fee_rate_per_instructions_increment - and self.tx_memory_limit == other.tx_memory_limit - ) - + return self.ledger_max_instructions== other.ledger_max_instructions and self.tx_max_instructions== other.tx_max_instructions and self.fee_rate_per_instructions_increment== other.fee_rate_per_instructions_increment and self.tx_memory_limit== other.tx_memory_limit def __str__(self): out = [ - f"ledger_max_instructions={self.ledger_max_instructions}", - f"tx_max_instructions={self.tx_max_instructions}", - f"fee_rate_per_instructions_increment={self.fee_rate_per_instructions_increment}", - f"tx_memory_limit={self.tx_memory_limit}", + f'ledger_max_instructions={self.ledger_max_instructions}', + f'tx_max_instructions={self.tx_max_instructions}', + f'fee_rate_per_instructions_increment={self.fee_rate_per_instructions_increment}', + f'tx_memory_limit={self.tx_memory_limit}', ] return f"" diff --git a/stellar_sdk/xdr/config_setting_contract_events_v0.py b/stellar_sdk/xdr/config_setting_contract_events_v0.py new file mode 100644 index 00000000..1249c076 --- /dev/null +++ b/stellar_sdk/xdr/config_setting_contract_events_v0.py @@ -0,0 +1,74 @@ +# This is an automatically generated file. +# DO NOT EDIT or your changes may be overwritten +from __future__ import annotations + +import base64 +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING +from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * + +from .uint32 import Uint32 +from .int64 import Int64 +__all__ = ['ConfigSettingContractEventsV0'] +class ConfigSettingContractEventsV0: + """ + XDR Source Code:: + + struct ConfigSettingContractEventsV0 + { + // Maximum size of events that a contract call can emit. + uint32 txMaxContractEventsSizeBytes; + // Fee for generating 1KB of contract events. + int64 feeContractEvents1KB; + }; + """ + def __init__( + self, + tx_max_contract_events_size_bytes: Uint32, + fee_contract_events1_kb: Int64, + ) -> None: + self.tx_max_contract_events_size_bytes = tx_max_contract_events_size_bytes + self.fee_contract_events1_kb = fee_contract_events1_kb + def pack(self, packer: Packer) -> None: + self.tx_max_contract_events_size_bytes.pack(packer) + self.fee_contract_events1_kb.pack(packer) + @classmethod + def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractEventsV0: + tx_max_contract_events_size_bytes = Uint32.unpack(unpacker) + fee_contract_events1_kb = Int64.unpack(unpacker) + return cls( + tx_max_contract_events_size_bytes=tx_max_contract_events_size_bytes, + fee_contract_events1_kb=fee_contract_events1_kb, + ) + def to_xdr_bytes(self) -> bytes: + packer = Packer() + self.pack(packer) + return packer.get_buffer() + + @classmethod + def from_xdr_bytes(cls, xdr: bytes) -> ConfigSettingContractEventsV0: + unpacker = Unpacker(xdr) + return cls.unpack(unpacker) + + def to_xdr(self) -> str: + xdr_bytes = self.to_xdr_bytes() + return base64.b64encode(xdr_bytes).decode() + + @classmethod + def from_xdr(cls, xdr: str) -> ConfigSettingContractEventsV0: + xdr_bytes = base64.b64decode(xdr.encode()) + return cls.from_xdr_bytes(xdr_bytes) + def __hash__(self): + return hash((self.tx_max_contract_events_size_bytes, self.fee_contract_events1_kb,)) + def __eq__(self, other: object): + if not isinstance(other, self.__class__): + return NotImplemented + return self.tx_max_contract_events_size_bytes== other.tx_max_contract_events_size_bytes and self.fee_contract_events1_kb== other.fee_contract_events1_kb + def __str__(self): + out = [ + f'tx_max_contract_events_size_bytes={self.tx_max_contract_events_size_bytes}', + f'fee_contract_events1_kb={self.fee_contract_events1_kb}', + ] + return f"" diff --git a/stellar_sdk/xdr/config_setting_contract_execution_lanes_v0.py b/stellar_sdk/xdr/config_setting_contract_execution_lanes_v0.py index 49c3f79c..d3224385 100644 --- a/stellar_sdk/xdr/config_setting_contract_execution_lanes_v0.py +++ b/stellar_sdk/xdr/config_setting_contract_execution_lanes_v0.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint32 import Uint32 - -__all__ = ["ConfigSettingContractExecutionLanesV0"] - - +__all__ = ['ConfigSettingContractExecutionLanesV0'] class ConfigSettingContractExecutionLanesV0: """ XDR Source Code:: @@ -21,23 +21,19 @@ class ConfigSettingContractExecutionLanesV0: uint32 ledgerMaxTxCount; }; """ - def __init__( self, ledger_max_tx_count: Uint32, ) -> None: self.ledger_max_tx_count = ledger_max_tx_count - def pack(self, packer: Packer) -> None: self.ledger_max_tx_count.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractExecutionLanesV0: ledger_max_tx_count = Uint32.unpack(unpacker) return cls( ledger_max_tx_count=ledger_max_tx_count, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -56,17 +52,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ConfigSettingContractExecutionLanesV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.ledger_max_tx_count,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.ledger_max_tx_count == other.ledger_max_tx_count - + return self.ledger_max_tx_count== other.ledger_max_tx_count def __str__(self): out = [ - f"ledger_max_tx_count={self.ledger_max_tx_count}", + f'ledger_max_tx_count={self.ledger_max_tx_count}', ] return f"" diff --git a/stellar_sdk/xdr/config_setting_contract_historical_data_v0.py b/stellar_sdk/xdr/config_setting_contract_historical_data_v0.py index 5dbe4924..aadc8bf7 100644 --- a/stellar_sdk/xdr/config_setting_contract_historical_data_v0.py +++ b/stellar_sdk/xdr/config_setting_contract_historical_data_v0.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int64 import Int64 - -__all__ = ["ConfigSettingContractHistoricalDataV0"] - - +__all__ = ['ConfigSettingContractHistoricalDataV0'] class ConfigSettingContractHistoricalDataV0: """ XDR Source Code:: @@ -20,23 +20,19 @@ class ConfigSettingContractHistoricalDataV0: int64 feeHistorical1KB; // Fee for storing 1KB in archives }; """ - def __init__( self, fee_historical1_kb: Int64, ) -> None: self.fee_historical1_kb = fee_historical1_kb - def pack(self, packer: Packer) -> None: self.fee_historical1_kb.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractHistoricalDataV0: fee_historical1_kb = Int64.unpack(unpacker) return cls( fee_historical1_kb=fee_historical1_kb, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ConfigSettingContractHistoricalDataV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.fee_historical1_kb,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.fee_historical1_kb == other.fee_historical1_kb - + return self.fee_historical1_kb== other.fee_historical1_kb def __str__(self): out = [ - f"fee_historical1_kb={self.fee_historical1_kb}", + f'fee_historical1_kb={self.fee_historical1_kb}', ] return f"" diff --git a/stellar_sdk/xdr/config_setting_contract_ledger_cost_v0.py b/stellar_sdk/xdr/config_setting_contract_ledger_cost_v0.py index 4ad0ee14..5dd38ec3 100644 --- a/stellar_sdk/xdr/config_setting_contract_ledger_cost_v0.py +++ b/stellar_sdk/xdr/config_setting_contract_ledger_cost_v0.py @@ -3,15 +3,28 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .int64 import Int64 +from .int64 import Int64 +from .int64 import Int64 +from .int64 import Int64 +from .int64 import Int64 from .int64 import Int64 from .uint32 import Uint32 - -__all__ = ["ConfigSettingContractLedgerCostV0"] - - +__all__ = ['ConfigSettingContractLedgerCostV0'] class ConfigSettingContractLedgerCostV0: """ XDR Source Code:: @@ -46,13 +59,12 @@ class ConfigSettingContractLedgerCostV0: int64 bucketListTargetSizeBytes; // Fee per 1KB write when the bucket list is empty int64 writeFee1KBBucketListLow; - // Fee per 1KB write when the bucket list has reached `bucketListTargetSizeBytes` + // Fee per 1KB write when the bucket list has reached `bucketListTargetSizeBytes` int64 writeFee1KBBucketListHigh; // Write fee multiplier for any additional data past the first `bucketListTargetSizeBytes` uint32 bucketListWriteFeeGrowthFactor; }; """ - def __init__( self, ledger_max_read_ledger_entries: Uint32, @@ -86,7 +98,6 @@ def __init__( self.write_fee1_kb_bucket_list_low = write_fee1_kb_bucket_list_low self.write_fee1_kb_bucket_list_high = write_fee1_kb_bucket_list_high self.bucket_list_write_fee_growth_factor = bucket_list_write_fee_growth_factor - def pack(self, packer: Packer) -> None: self.ledger_max_read_ledger_entries.pack(packer) self.ledger_max_read_bytes.pack(packer) @@ -103,7 +114,6 @@ def pack(self, packer: Packer) -> None: self.write_fee1_kb_bucket_list_low.pack(packer) self.write_fee1_kb_bucket_list_high.pack(packer) self.bucket_list_write_fee_growth_factor.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractLedgerCostV0: ledger_max_read_ledger_entries = Uint32.unpack(unpacker) @@ -138,7 +148,6 @@ def unpack(cls, unpacker: Unpacker) -> ConfigSettingContractLedgerCostV0: write_fee1_kb_bucket_list_high=write_fee1_kb_bucket_list_high, bucket_list_write_fee_growth_factor=bucket_list_write_fee_growth_factor, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -157,70 +166,28 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ConfigSettingContractLedgerCostV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_max_read_ledger_entries, - self.ledger_max_read_bytes, - self.ledger_max_write_ledger_entries, - self.ledger_max_write_bytes, - self.tx_max_read_ledger_entries, - self.tx_max_read_bytes, - self.tx_max_write_ledger_entries, - self.tx_max_write_bytes, - self.fee_read_ledger_entry, - self.fee_write_ledger_entry, - self.fee_read1_kb, - self.bucket_list_target_size_bytes, - self.write_fee1_kb_bucket_list_low, - self.write_fee1_kb_bucket_list_high, - self.bucket_list_write_fee_growth_factor, - ) - ) - + return hash((self.ledger_max_read_ledger_entries, self.ledger_max_read_bytes, self.ledger_max_write_ledger_entries, self.ledger_max_write_bytes, self.tx_max_read_ledger_entries, self.tx_max_read_bytes, self.tx_max_write_ledger_entries, self.tx_max_write_bytes, self.fee_read_ledger_entry, self.fee_write_ledger_entry, self.fee_read1_kb, self.bucket_list_target_size_bytes, self.write_fee1_kb_bucket_list_low, self.write_fee1_kb_bucket_list_high, self.bucket_list_write_fee_growth_factor,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_max_read_ledger_entries == other.ledger_max_read_ledger_entries - and self.ledger_max_read_bytes == other.ledger_max_read_bytes - and self.ledger_max_write_ledger_entries - == other.ledger_max_write_ledger_entries - and self.ledger_max_write_bytes == other.ledger_max_write_bytes - and self.tx_max_read_ledger_entries == other.tx_max_read_ledger_entries - and self.tx_max_read_bytes == other.tx_max_read_bytes - and self.tx_max_write_ledger_entries == other.tx_max_write_ledger_entries - and self.tx_max_write_bytes == other.tx_max_write_bytes - and self.fee_read_ledger_entry == other.fee_read_ledger_entry - and self.fee_write_ledger_entry == other.fee_write_ledger_entry - and self.fee_read1_kb == other.fee_read1_kb - and self.bucket_list_target_size_bytes - == other.bucket_list_target_size_bytes - and self.write_fee1_kb_bucket_list_low - == other.write_fee1_kb_bucket_list_low - and self.write_fee1_kb_bucket_list_high - == other.write_fee1_kb_bucket_list_high - and self.bucket_list_write_fee_growth_factor - == other.bucket_list_write_fee_growth_factor - ) - + return self.ledger_max_read_ledger_entries== other.ledger_max_read_ledger_entries and self.ledger_max_read_bytes== other.ledger_max_read_bytes and self.ledger_max_write_ledger_entries== other.ledger_max_write_ledger_entries and self.ledger_max_write_bytes== other.ledger_max_write_bytes and self.tx_max_read_ledger_entries== other.tx_max_read_ledger_entries and self.tx_max_read_bytes== other.tx_max_read_bytes and self.tx_max_write_ledger_entries== other.tx_max_write_ledger_entries and self.tx_max_write_bytes== other.tx_max_write_bytes and self.fee_read_ledger_entry== other.fee_read_ledger_entry and self.fee_write_ledger_entry== other.fee_write_ledger_entry and self.fee_read1_kb== other.fee_read1_kb and self.bucket_list_target_size_bytes== other.bucket_list_target_size_bytes and self.write_fee1_kb_bucket_list_low== other.write_fee1_kb_bucket_list_low and self.write_fee1_kb_bucket_list_high== other.write_fee1_kb_bucket_list_high and self.bucket_list_write_fee_growth_factor== other.bucket_list_write_fee_growth_factor def __str__(self): out = [ - f"ledger_max_read_ledger_entries={self.ledger_max_read_ledger_entries}", - f"ledger_max_read_bytes={self.ledger_max_read_bytes}", - f"ledger_max_write_ledger_entries={self.ledger_max_write_ledger_entries}", - f"ledger_max_write_bytes={self.ledger_max_write_bytes}", - f"tx_max_read_ledger_entries={self.tx_max_read_ledger_entries}", - f"tx_max_read_bytes={self.tx_max_read_bytes}", - f"tx_max_write_ledger_entries={self.tx_max_write_ledger_entries}", - f"tx_max_write_bytes={self.tx_max_write_bytes}", - f"fee_read_ledger_entry={self.fee_read_ledger_entry}", - f"fee_write_ledger_entry={self.fee_write_ledger_entry}", - f"fee_read1_kb={self.fee_read1_kb}", - f"bucket_list_target_size_bytes={self.bucket_list_target_size_bytes}", - f"write_fee1_kb_bucket_list_low={self.write_fee1_kb_bucket_list_low}", - f"write_fee1_kb_bucket_list_high={self.write_fee1_kb_bucket_list_high}", - f"bucket_list_write_fee_growth_factor={self.bucket_list_write_fee_growth_factor}", + f'ledger_max_read_ledger_entries={self.ledger_max_read_ledger_entries}', + f'ledger_max_read_bytes={self.ledger_max_read_bytes}', + f'ledger_max_write_ledger_entries={self.ledger_max_write_ledger_entries}', + f'ledger_max_write_bytes={self.ledger_max_write_bytes}', + f'tx_max_read_ledger_entries={self.tx_max_read_ledger_entries}', + f'tx_max_read_bytes={self.tx_max_read_bytes}', + f'tx_max_write_ledger_entries={self.tx_max_write_ledger_entries}', + f'tx_max_write_bytes={self.tx_max_write_bytes}', + f'fee_read_ledger_entry={self.fee_read_ledger_entry}', + f'fee_write_ledger_entry={self.fee_write_ledger_entry}', + f'fee_read1_kb={self.fee_read1_kb}', + f'bucket_list_target_size_bytes={self.bucket_list_target_size_bytes}', + f'write_fee1_kb_bucket_list_low={self.write_fee1_kb_bucket_list_low}', + f'write_fee1_kb_bucket_list_high={self.write_fee1_kb_bucket_list_high}', + f'bucket_list_write_fee_growth_factor={self.bucket_list_write_fee_growth_factor}', ] return f"" diff --git a/stellar_sdk/xdr/config_setting_entry.py b/stellar_sdk/xdr/config_setting_entry.py index 59e77d1f..a6f80f0a 100644 --- a/stellar_sdk/xdr/config_setting_entry.py +++ b/stellar_sdk/xdr/config_setting_entry.py @@ -3,30 +3,28 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .config_setting_contract_bandwidth_v0 import ConfigSettingContractBandwidthV0 +from .config_setting_id import ConfigSettingID +from .uint32 import Uint32 from .config_setting_contract_compute_v0 import ConfigSettingContractComputeV0 -from .config_setting_contract_events_v0 import ConfigSettingContractEventsV0 -from .config_setting_contract_execution_lanes_v0 import ( - ConfigSettingContractExecutionLanesV0, -) -from .config_setting_contract_historical_data_v0 import ( - ConfigSettingContractHistoricalDataV0, -) from .config_setting_contract_ledger_cost_v0 import ConfigSettingContractLedgerCostV0 -from .config_setting_id import ConfigSettingID +from .config_setting_contract_historical_data_v0 import ConfigSettingContractHistoricalDataV0 +from .config_setting_contract_events_v0 import ConfigSettingContractEventsV0 +from .config_setting_contract_bandwidth_v0 import ConfigSettingContractBandwidthV0 from .contract_cost_params import ContractCostParams -from .eviction_iterator import EvictionIterator -from .state_expiration_settings import StateExpirationSettings +from .contract_cost_params import ContractCostParams +from .uint32 import Uint32 from .uint32 import Uint32 +from .state_expiration_settings import StateExpirationSettings +from .config_setting_contract_execution_lanes_v0 import ConfigSettingContractExecutionLanesV0 from .uint64 import Uint64 - -__all__ = ["ConfigSettingEntry"] - - +from .eviction_iterator import EvictionIterator +__all__ = ['ConfigSettingEntry'] class ConfigSettingEntry: """ XDR Source Code:: @@ -63,7 +61,6 @@ class ConfigSettingEntry: EvictionIterator evictionIterator; }; """ - def __init__( self, config_setting_id: ConfigSettingID, @@ -83,13 +80,8 @@ def __init__( eviction_iterator: EvictionIterator = None, ) -> None: _expect_max_length = 4294967295 - if ( - bucket_list_size_window - and len(bucket_list_size_window) > _expect_max_length - ): - raise ValueError( - f"The maximum length of `bucket_list_size_window` should be {_expect_max_length}, but got {len(bucket_list_size_window)}." - ) + if bucket_list_size_window and len(bucket_list_size_window) > _expect_max_length: + raise ValueError(f"The maximum length of `bucket_list_size_window` should be {_expect_max_length}, but got {len(bucket_list_size_window)}.") self.config_setting_id = config_setting_id self.contract_max_size_bytes = contract_max_size_bytes self.contract_compute = contract_compute @@ -105,13 +97,9 @@ def __init__( self.contract_execution_lanes = contract_execution_lanes self.bucket_list_size_window = bucket_list_size_window self.eviction_iterator = eviction_iterator - def pack(self, packer: Packer) -> None: self.config_setting_id.pack(packer) - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES: if self.contract_max_size_bytes is None: raise ValueError("contract_max_size_bytes should not be None.") self.contract_max_size_bytes.pack(packer) @@ -121,18 +109,12 @@ def pack(self, packer: Packer) -> None: raise ValueError("contract_compute should not be None.") self.contract_compute.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_LEDGER_COST_V0 - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_LEDGER_COST_V0: if self.contract_ledger_cost is None: raise ValueError("contract_ledger_cost should not be None.") self.contract_ledger_cost.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0 - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0: if self.contract_historical_data is None: raise ValueError("contract_historical_data should not be None.") self.contract_historical_data.pack(packer) @@ -142,42 +124,27 @@ def pack(self, packer: Packer) -> None: raise ValueError("contract_events should not be None.") self.contract_events.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_BANDWIDTH_V0 - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_BANDWIDTH_V0: if self.contract_bandwidth is None: raise ValueError("contract_bandwidth should not be None.") self.contract_bandwidth.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS: if self.contract_cost_params_cpu_insns is None: raise ValueError("contract_cost_params_cpu_insns should not be None.") self.contract_cost_params_cpu_insns.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES: if self.contract_cost_params_mem_bytes is None: raise ValueError("contract_cost_params_mem_bytes should not be None.") self.contract_cost_params_mem_bytes.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES: if self.contract_data_key_size_bytes is None: raise ValueError("contract_data_key_size_bytes should not be None.") self.contract_data_key_size_bytes.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: if self.contract_data_entry_size_bytes is None: raise ValueError("contract_data_entry_size_bytes should not be None.") self.contract_data_entry_size_bytes.pack(packer) @@ -187,18 +154,12 @@ def pack(self, packer: Packer) -> None: raise ValueError("state_expiration_settings should not be None.") self.state_expiration_settings.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_EXECUTION_LANES - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_EXECUTION_LANES: if self.contract_execution_lanes is None: raise ValueError("contract_execution_lanes should not be None.") self.contract_execution_lanes.pack(packer) return - if ( - self.config_setting_id - == ConfigSettingID.CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW - ): + if self.config_setting_id == ConfigSettingID.CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: if self.bucket_list_size_window is None: raise ValueError("bucket_list_size_window should not be None.") packer.pack_uint(len(self.bucket_list_size_window)) @@ -210,115 +171,55 @@ def pack(self, packer: Packer) -> None: raise ValueError("eviction_iterator should not be None.") self.eviction_iterator.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> ConfigSettingEntry: config_setting_id = ConfigSettingID.unpack(unpacker) if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES: contract_max_size_bytes = Uint32.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, - contract_max_size_bytes=contract_max_size_bytes, - ) + return cls(config_setting_id=config_setting_id, contract_max_size_bytes=contract_max_size_bytes) if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_COMPUTE_V0: contract_compute = ConfigSettingContractComputeV0.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, contract_compute=contract_compute - ) + return cls(config_setting_id=config_setting_id, contract_compute=contract_compute) if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_LEDGER_COST_V0: contract_ledger_cost = ConfigSettingContractLedgerCostV0.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, - contract_ledger_cost=contract_ledger_cost, - ) - if ( - config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0 - ): - contract_historical_data = ConfigSettingContractHistoricalDataV0.unpack( - unpacker - ) - return cls( - config_setting_id=config_setting_id, - contract_historical_data=contract_historical_data, - ) + return cls(config_setting_id=config_setting_id, contract_ledger_cost=contract_ledger_cost) + if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0: + contract_historical_data = ConfigSettingContractHistoricalDataV0.unpack(unpacker) + return cls(config_setting_id=config_setting_id, contract_historical_data=contract_historical_data) if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_EVENTS_V0: contract_events = ConfigSettingContractEventsV0.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, contract_events=contract_events - ) + return cls(config_setting_id=config_setting_id, contract_events=contract_events) if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_BANDWIDTH_V0: contract_bandwidth = ConfigSettingContractBandwidthV0.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, - contract_bandwidth=contract_bandwidth, - ) - if ( - config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS - ): + return cls(config_setting_id=config_setting_id, contract_bandwidth=contract_bandwidth) + if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS: contract_cost_params_cpu_insns = ContractCostParams.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, - contract_cost_params_cpu_insns=contract_cost_params_cpu_insns, - ) - if ( - config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES - ): + return cls(config_setting_id=config_setting_id, contract_cost_params_cpu_insns=contract_cost_params_cpu_insns) + if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES: contract_cost_params_mem_bytes = ContractCostParams.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, - contract_cost_params_mem_bytes=contract_cost_params_mem_bytes, - ) - if ( - config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES - ): + return cls(config_setting_id=config_setting_id, contract_cost_params_mem_bytes=contract_cost_params_mem_bytes) + if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES: contract_data_key_size_bytes = Uint32.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, - contract_data_key_size_bytes=contract_data_key_size_bytes, - ) - if ( - config_setting_id - == ConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES - ): + return cls(config_setting_id=config_setting_id, contract_data_key_size_bytes=contract_data_key_size_bytes) + if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: contract_data_entry_size_bytes = Uint32.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, - contract_data_entry_size_bytes=contract_data_entry_size_bytes, - ) + return cls(config_setting_id=config_setting_id, contract_data_entry_size_bytes=contract_data_entry_size_bytes) if config_setting_id == ConfigSettingID.CONFIG_SETTING_STATE_EXPIRATION: state_expiration_settings = StateExpirationSettings.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, - state_expiration_settings=state_expiration_settings, - ) + return cls(config_setting_id=config_setting_id, state_expiration_settings=state_expiration_settings) if config_setting_id == ConfigSettingID.CONFIG_SETTING_CONTRACT_EXECUTION_LANES: - contract_execution_lanes = ConfigSettingContractExecutionLanesV0.unpack( - unpacker - ) - return cls( - config_setting_id=config_setting_id, - contract_execution_lanes=contract_execution_lanes, - ) + contract_execution_lanes = ConfigSettingContractExecutionLanesV0.unpack(unpacker) + return cls(config_setting_id=config_setting_id, contract_execution_lanes=contract_execution_lanes) if config_setting_id == ConfigSettingID.CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: length = unpacker.unpack_uint() bucket_list_size_window = [] for _ in range(length): bucket_list_size_window.append(Uint64.unpack(unpacker)) - return cls( - config_setting_id=config_setting_id, - bucket_list_size_window=bucket_list_size_window, - ) + return cls(config_setting_id=config_setting_id, bucket_list_size_window=bucket_list_size_window) if config_setting_id == ConfigSettingID.CONFIG_SETTING_EVICTION_ITERATOR: eviction_iterator = EvictionIterator.unpack(unpacker) - return cls( - config_setting_id=config_setting_id, eviction_iterator=eviction_iterator - ) + return cls(config_setting_id=config_setting_id, eviction_iterator=eviction_iterator) return cls(config_setting_id=config_setting_id) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -337,95 +238,27 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ConfigSettingEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.config_setting_id, - self.contract_max_size_bytes, - self.contract_compute, - self.contract_ledger_cost, - self.contract_historical_data, - self.contract_events, - self.contract_bandwidth, - self.contract_cost_params_cpu_insns, - self.contract_cost_params_mem_bytes, - self.contract_data_key_size_bytes, - self.contract_data_entry_size_bytes, - self.state_expiration_settings, - self.contract_execution_lanes, - self.bucket_list_size_window, - self.eviction_iterator, - ) - ) - + return hash((self.config_setting_id, self.contract_max_size_bytes, self.contract_compute, self.contract_ledger_cost, self.contract_historical_data, self.contract_events, self.contract_bandwidth, self.contract_cost_params_cpu_insns, self.contract_cost_params_mem_bytes, self.contract_data_key_size_bytes, self.contract_data_entry_size_bytes, self.state_expiration_settings, self.contract_execution_lanes, self.bucket_list_size_window, self.eviction_iterator,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.config_setting_id == other.config_setting_id - and self.contract_max_size_bytes == other.contract_max_size_bytes - and self.contract_compute == other.contract_compute - and self.contract_ledger_cost == other.contract_ledger_cost - and self.contract_historical_data == other.contract_historical_data - and self.contract_events == other.contract_events - and self.contract_bandwidth == other.contract_bandwidth - and self.contract_cost_params_cpu_insns - == other.contract_cost_params_cpu_insns - and self.contract_cost_params_mem_bytes - == other.contract_cost_params_mem_bytes - and self.contract_data_key_size_bytes == other.contract_data_key_size_bytes - and self.contract_data_entry_size_bytes - == other.contract_data_entry_size_bytes - and self.state_expiration_settings == other.state_expiration_settings - and self.contract_execution_lanes == other.contract_execution_lanes - and self.bucket_list_size_window == other.bucket_list_size_window - and self.eviction_iterator == other.eviction_iterator - ) - + return self.config_setting_id== other.config_setting_id and self.contract_max_size_bytes== other.contract_max_size_bytes and self.contract_compute== other.contract_compute and self.contract_ledger_cost== other.contract_ledger_cost and self.contract_historical_data== other.contract_historical_data and self.contract_events== other.contract_events and self.contract_bandwidth== other.contract_bandwidth and self.contract_cost_params_cpu_insns== other.contract_cost_params_cpu_insns and self.contract_cost_params_mem_bytes== other.contract_cost_params_mem_bytes and self.contract_data_key_size_bytes== other.contract_data_key_size_bytes and self.contract_data_entry_size_bytes== other.contract_data_entry_size_bytes and self.state_expiration_settings== other.state_expiration_settings and self.contract_execution_lanes== other.contract_execution_lanes and self.bucket_list_size_window== other.bucket_list_size_window and self.eviction_iterator== other.eviction_iterator def __str__(self): out = [] - out.append(f"config_setting_id={self.config_setting_id}") - out.append( - f"contract_max_size_bytes={self.contract_max_size_bytes}" - ) if self.contract_max_size_bytes is not None else None - out.append( - f"contract_compute={self.contract_compute}" - ) if self.contract_compute is not None else None - out.append( - f"contract_ledger_cost={self.contract_ledger_cost}" - ) if self.contract_ledger_cost is not None else None - out.append( - f"contract_historical_data={self.contract_historical_data}" - ) if self.contract_historical_data is not None else None - out.append( - f"contract_events={self.contract_events}" - ) if self.contract_events is not None else None - out.append( - f"contract_bandwidth={self.contract_bandwidth}" - ) if self.contract_bandwidth is not None else None - out.append( - f"contract_cost_params_cpu_insns={self.contract_cost_params_cpu_insns}" - ) if self.contract_cost_params_cpu_insns is not None else None - out.append( - f"contract_cost_params_mem_bytes={self.contract_cost_params_mem_bytes}" - ) if self.contract_cost_params_mem_bytes is not None else None - out.append( - f"contract_data_key_size_bytes={self.contract_data_key_size_bytes}" - ) if self.contract_data_key_size_bytes is not None else None - out.append( - f"contract_data_entry_size_bytes={self.contract_data_entry_size_bytes}" - ) if self.contract_data_entry_size_bytes is not None else None - out.append( - f"state_expiration_settings={self.state_expiration_settings}" - ) if self.state_expiration_settings is not None else None - out.append( - f"contract_execution_lanes={self.contract_execution_lanes}" - ) if self.contract_execution_lanes is not None else None - out.append( - f"bucket_list_size_window={self.bucket_list_size_window}" - ) if self.bucket_list_size_window is not None else None - out.append( - f"eviction_iterator={self.eviction_iterator}" - ) if self.eviction_iterator is not None else None + out.append(f'config_setting_id={self.config_setting_id}') + out.append(f'contract_max_size_bytes={self.contract_max_size_bytes}') if self.contract_max_size_bytes is not None else None + out.append(f'contract_compute={self.contract_compute}') if self.contract_compute is not None else None + out.append(f'contract_ledger_cost={self.contract_ledger_cost}') if self.contract_ledger_cost is not None else None + out.append(f'contract_historical_data={self.contract_historical_data}') if self.contract_historical_data is not None else None + out.append(f'contract_events={self.contract_events}') if self.contract_events is not None else None + out.append(f'contract_bandwidth={self.contract_bandwidth}') if self.contract_bandwidth is not None else None + out.append(f'contract_cost_params_cpu_insns={self.contract_cost_params_cpu_insns}') if self.contract_cost_params_cpu_insns is not None else None + out.append(f'contract_cost_params_mem_bytes={self.contract_cost_params_mem_bytes}') if self.contract_cost_params_mem_bytes is not None else None + out.append(f'contract_data_key_size_bytes={self.contract_data_key_size_bytes}') if self.contract_data_key_size_bytes is not None else None + out.append(f'contract_data_entry_size_bytes={self.contract_data_entry_size_bytes}') if self.contract_data_entry_size_bytes is not None else None + out.append(f'state_expiration_settings={self.state_expiration_settings}') if self.state_expiration_settings is not None else None + out.append(f'contract_execution_lanes={self.contract_execution_lanes}') if self.contract_execution_lanes is not None else None + out.append(f'bucket_list_size_window={self.bucket_list_size_window}') if self.bucket_list_size_window is not None else None + out.append(f'eviction_iterator={self.eviction_iterator}') if self.eviction_iterator is not None else None return f"" diff --git a/stellar_sdk/xdr/config_setting_id.py b/stellar_sdk/xdr/config_setting_id.py index c176dc4b..059f574b 100644 --- a/stellar_sdk/xdr/config_setting_id.py +++ b/stellar_sdk/xdr/config_setting_id.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ConfigSettingID"] - - +__all__ = ['ConfigSettingID'] class ConfigSettingID(IntEnum): """ XDR Source Code:: @@ -32,7 +32,6 @@ class ConfigSettingID(IntEnum): CONFIG_SETTING_EVICTION_ITERATOR = 13 }; """ - CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES = 0 CONFIG_SETTING_CONTRACT_COMPUTE_V0 = 1 CONFIG_SETTING_CONTRACT_LEDGER_COST_V0 = 2 @@ -47,7 +46,6 @@ class ConfigSettingID(IntEnum): CONFIG_SETTING_CONTRACT_EXECUTION_LANES = 11 CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW = 12 CONFIG_SETTING_EVICTION_ITERATOR = 13 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -55,7 +53,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ConfigSettingID: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/config_upgrade_set.py b/stellar_sdk/xdr/config_upgrade_set.py index a0e0b35e..c0dbff61 100644 --- a/stellar_sdk/xdr/config_upgrade_set.py +++ b/stellar_sdk/xdr/config_upgrade_set.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .config_setting_entry import ConfigSettingEntry - -__all__ = ["ConfigUpgradeSet"] - - +__all__ = ['ConfigUpgradeSet'] class ConfigUpgradeSet: """ XDR Source Code:: @@ -20,23 +19,18 @@ class ConfigUpgradeSet: ConfigSettingEntry updatedEntry<>; }; """ - def __init__( self, updated_entry: List[ConfigSettingEntry], ) -> None: _expect_max_length = 4294967295 if updated_entry and len(updated_entry) > _expect_max_length: - raise ValueError( - f"The maximum length of `updated_entry` should be {_expect_max_length}, but got {len(updated_entry)}." - ) + raise ValueError(f"The maximum length of `updated_entry` should be {_expect_max_length}, but got {len(updated_entry)}.") self.updated_entry = updated_entry - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.updated_entry)) for updated_entry_item in self.updated_entry: updated_entry_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ConfigUpgradeSet: length = unpacker.unpack_uint() @@ -46,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> ConfigUpgradeSet: return cls( updated_entry=updated_entry, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -65,17 +58,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ConfigUpgradeSet: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.updated_entry,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.updated_entry == other.updated_entry - + return self.updated_entry== other.updated_entry def __str__(self): out = [ - f"updated_entry={self.updated_entry}", + f'updated_entry={self.updated_entry}', ] return f"" diff --git a/stellar_sdk/xdr/config_upgrade_set_key.py b/stellar_sdk/xdr/config_upgrade_set_key.py index c1eb49b7..fc8e6148 100644 --- a/stellar_sdk/xdr/config_upgrade_set_key.py +++ b/stellar_sdk/xdr/config_upgrade_set_key.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash - -__all__ = ["ConfigUpgradeSetKey"] - - +from .hash import Hash +__all__ = ['ConfigUpgradeSetKey'] class ConfigUpgradeSetKey: """ XDR Source Code:: @@ -20,7 +21,6 @@ class ConfigUpgradeSetKey: Hash contentHash; }; """ - def __init__( self, contract_id: Hash, @@ -28,11 +28,9 @@ def __init__( ) -> None: self.contract_id = contract_id self.content_hash = content_hash - def pack(self, packer: Packer) -> None: self.contract_id.pack(packer) self.content_hash.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ConfigUpgradeSetKey: contract_id = Hash.unpack(unpacker) @@ -41,7 +39,6 @@ def unpack(cls, unpacker: Unpacker) -> ConfigUpgradeSetKey: contract_id=contract_id, content_hash=content_hash, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -60,26 +57,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ConfigUpgradeSetKey: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.contract_id, - self.content_hash, - ) - ) - + return hash((self.contract_id, self.content_hash,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.contract_id == other.contract_id - and self.content_hash == other.content_hash - ) - + return self.contract_id== other.contract_id and self.content_hash== other.content_hash def __str__(self): out = [ - f"contract_id={self.contract_id}", - f"content_hash={self.content_hash}", + f'contract_id={self.contract_id}', + f'content_hash={self.content_hash}', ] return f"" diff --git a/stellar_sdk/xdr/contract_code_entry.py b/stellar_sdk/xdr/contract_code_entry.py index f2ea28b3..2a39c73f 100644 --- a/stellar_sdk/xdr/contract_code_entry.py +++ b/stellar_sdk/xdr/contract_code_entry.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque from .extension_point import ExtensionPoint from .hash import Hash - -__all__ = ["ContractCodeEntry"] - - +__all__ = ['ContractCodeEntry'] class ContractCodeEntry: """ XDR Source Code:: @@ -24,7 +23,6 @@ class ContractCodeEntry: opaque code<>; }; """ - def __init__( self, ext: ExtensionPoint, @@ -34,12 +32,10 @@ def __init__( self.ext = ext self.hash = hash self.code = code - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.hash.pack(packer) Opaque(self.code, 4294967295, False).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractCodeEntry: ext = ExtensionPoint.unpack(unpacker) @@ -50,7 +46,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractCodeEntry: hash=hash, code=code, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +64,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractCodeEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.hash, - self.code, - ) - ) - + return hash((self.ext, self.hash, self.code,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.hash == other.hash - and self.code == other.code - ) - + return self.ext== other.ext and self.hash== other.hash and self.code== other.code def __str__(self): out = [ - f"ext={self.ext}", - f"hash={self.hash}", - f"code={self.code}", + f'ext={self.ext}', + f'hash={self.hash}', + f'code={self.code}', ] return f"" diff --git a/stellar_sdk/xdr/contract_cost_param_entry.py b/stellar_sdk/xdr/contract_cost_param_entry.py index 2d3a68a4..a3b2b2c3 100644 --- a/stellar_sdk/xdr/contract_cost_param_entry.py +++ b/stellar_sdk/xdr/contract_cost_param_entry.py @@ -3,15 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .extension_point import ExtensionPoint from .int64 import Int64 - -__all__ = ["ContractCostParamEntry"] - - +from .int64 import Int64 +__all__ = ['ContractCostParamEntry'] class ContractCostParamEntry: """ XDR Source Code:: @@ -24,7 +25,6 @@ class ContractCostParamEntry: int64 linearTerm; }; """ - def __init__( self, ext: ExtensionPoint, @@ -34,12 +34,10 @@ def __init__( self.ext = ext self.const_term = const_term self.linear_term = linear_term - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.const_term.pack(packer) self.linear_term.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractCostParamEntry: ext = ExtensionPoint.unpack(unpacker) @@ -50,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractCostParamEntry: const_term=const_term, linear_term=linear_term, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +66,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractCostParamEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.const_term, - self.linear_term, - ) - ) - + return hash((self.ext, self.const_term, self.linear_term,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.const_term == other.const_term - and self.linear_term == other.linear_term - ) - + return self.ext== other.ext and self.const_term== other.const_term and self.linear_term== other.linear_term def __str__(self): out = [ - f"ext={self.ext}", - f"const_term={self.const_term}", - f"linear_term={self.linear_term}", + f'ext={self.ext}', + f'const_term={self.const_term}', + f'linear_term={self.linear_term}', ] return f"" diff --git a/stellar_sdk/xdr/contract_cost_params.py b/stellar_sdk/xdr/contract_cost_params.py index e7411691..0e5658e5 100644 --- a/stellar_sdk/xdr/contract_cost_params.py +++ b/stellar_sdk/xdr/contract_cost_params.py @@ -3,36 +3,29 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .contract_cost_param_entry import ContractCostParamEntry - -__all__ = ["ContractCostParams"] - +from .contract_cost_param_entry import ContractCostParamEntry +__all__ = ['ContractCostParams'] class ContractCostParams: """ XDR Source Code:: typedef ContractCostParamEntry ContractCostParams; """ - def __init__(self, contract_cost_params: List[ContractCostParamEntry]) -> None: _expect_max_length = CONTRACT_COST_COUNT_LIMIT if contract_cost_params and len(contract_cost_params) > _expect_max_length: - raise ValueError( - f"The maximum length of `contract_cost_params` should be {_expect_max_length}, but got {len(contract_cost_params)}." - ) + raise ValueError(f"The maximum length of `contract_cost_params` should be {_expect_max_length}, but got {len(contract_cost_params)}.") self.contract_cost_params = contract_cost_params - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.contract_cost_params)) for contract_cost_params_item in self.contract_cost_params: contract_cost_params_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractCostParams: length = unpacker.unpack_uint() @@ -40,7 +33,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractCostParams: for _ in range(length): contract_cost_params.append(ContractCostParamEntry.unpack(unpacker)) return cls(contract_cost_params) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -59,16 +51,12 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractCostParams: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.contract_cost_params) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented return self.contract_cost_params == other.contract_cost_params def __str__(self): - return ( - f"" - ) + return f"" diff --git a/stellar_sdk/xdr/contract_cost_type.py b/stellar_sdk/xdr/contract_cost_type.py index afbb30e1..22bb6398 100644 --- a/stellar_sdk/xdr/contract_cost_type.py +++ b/stellar_sdk/xdr/contract_cost_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ContractCostType"] - - +__all__ = ['ContractCostType'] class ContractCostType(IntEnum): """ XDR Source Code:: @@ -28,7 +28,7 @@ class ContractCostType(IntEnum): // Cost of a host function dispatch, not including the actual work done by // the function nor the cost of VM invocation machinary DispatchHostFunction = 5, - // Cost of visiting a host object from the host object storage. Exists to + // Cost of visiting a host object from the host object storage. Exists to // make sure some baseline cost coverage, i.e. repeatly visiting objects // by the guest will always incur some charges. VisitObject = 6, @@ -77,7 +77,6 @@ class ContractCostType(IntEnum): Int256Shift = 27 }; """ - WasmInsnExec = 0 WasmMemAlloc = 1 HostMemAlloc = 2 @@ -106,7 +105,6 @@ class ContractCostType(IntEnum): Int256Div = 25 Int256Pow = 26 Int256Shift = 27 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -114,7 +112,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ContractCostType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/contract_data_durability.py b/stellar_sdk/xdr/contract_data_durability.py index b741716b..d7153642 100644 --- a/stellar_sdk/xdr/contract_data_durability.py +++ b/stellar_sdk/xdr/contract_data_durability.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ContractDataDurability"] - - +__all__ = ['ContractDataDurability'] class ContractDataDurability(IntEnum): """ XDR Source Code:: @@ -19,10 +19,8 @@ class ContractDataDurability(IntEnum): PERSISTENT = 1 }; """ - TEMPORARY = 0 PERSISTENT = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -30,7 +28,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ContractDataDurability: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/contract_data_entry.py b/stellar_sdk/xdr/contract_data_entry.py index 11ef3a86..75a85cfa 100644 --- a/stellar_sdk/xdr/contract_data_entry.py +++ b/stellar_sdk/xdr/contract_data_entry.py @@ -3,17 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .contract_data_durability import ContractDataDurability from .extension_point import ExtensionPoint from .sc_address import SCAddress from .sc_val import SCVal - -__all__ = ["ContractDataEntry"] - - +from .contract_data_durability import ContractDataDurability +from .sc_val import SCVal +__all__ = ['ContractDataEntry'] class ContractDataEntry: """ XDR Source Code:: @@ -27,7 +28,6 @@ class ContractDataEntry: SCVal val; }; """ - def __init__( self, ext: ExtensionPoint, @@ -41,14 +41,12 @@ def __init__( self.key = key self.durability = durability self.val = val - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.contract.pack(packer) self.key.pack(packer) self.durability.pack(packer) self.val.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractDataEntry: ext = ExtensionPoint.unpack(unpacker) @@ -63,7 +61,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractDataEntry: durability=durability, val=val, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -82,35 +79,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractDataEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.contract, - self.key, - self.durability, - self.val, - ) - ) - + return hash((self.ext, self.contract, self.key, self.durability, self.val,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.contract == other.contract - and self.key == other.key - and self.durability == other.durability - and self.val == other.val - ) - + return self.ext== other.ext and self.contract== other.contract and self.key== other.key and self.durability== other.durability and self.val== other.val def __str__(self): out = [ - f"ext={self.ext}", - f"contract={self.contract}", - f"key={self.key}", - f"durability={self.durability}", - f"val={self.val}", + f'ext={self.ext}', + f'contract={self.contract}', + f'key={self.key}', + f'durability={self.durability}', + f'val={self.val}', ] return f"" diff --git a/stellar_sdk/xdr/contract_event.py b/stellar_sdk/xdr/contract_event.py index fd1c92f7..fd13985d 100644 --- a/stellar_sdk/xdr/contract_event.py +++ b/stellar_sdk/xdr/contract_event.py @@ -3,18 +3,17 @@ from __future__ import annotations import base64 -from typing import Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .contract_event_body import ContractEventBody -from .contract_event_type import ContractEventType from .extension_point import ExtensionPoint from .hash import Hash - -__all__ = ["ContractEvent"] - - +from .contract_event_type import ContractEventType +from .contract_event_body import ContractEventBody +__all__ = ['ContractEvent'] class ContractEvent: """ XDR Source Code:: @@ -40,7 +39,6 @@ class ContractEvent: body; }; """ - def __init__( self, ext: ExtensionPoint, @@ -52,7 +50,6 @@ def __init__( self.contract_id = contract_id self.type = type self.body = body - def pack(self, packer: Packer) -> None: self.ext.pack(packer) if self.contract_id is None: @@ -62,7 +59,6 @@ def pack(self, packer: Packer) -> None: self.contract_id.pack(packer) self.type.pack(packer) self.body.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractEvent: ext = ExtensionPoint.unpack(unpacker) @@ -75,7 +71,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractEvent: type=type, body=body, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -94,32 +89,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractEvent: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.contract_id, - self.type, - self.body, - ) - ) - + return hash((self.ext, self.contract_id, self.type, self.body,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.contract_id == other.contract_id - and self.type == other.type - and self.body == other.body - ) - + return self.ext== other.ext and self.contract_id== other.contract_id and self.type== other.type and self.body== other.body def __str__(self): out = [ - f"ext={self.ext}", - f"contract_id={self.contract_id}", - f"type={self.type}", - f"body={self.body}", + f'ext={self.ext}', + f'contract_id={self.contract_id}', + f'type={self.type}', + f'body={self.body}', ] return f"" diff --git a/stellar_sdk/xdr/contract_event_body.py b/stellar_sdk/xdr/contract_event_body.py index 378ad283..cce58699 100644 --- a/stellar_sdk/xdr/contract_event_body.py +++ b/stellar_sdk/xdr/contract_event_body.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .contract_event_v0 import ContractEventV0 - -__all__ = ["ContractEventBody"] - - +__all__ = ['ContractEventBody'] class ContractEventBody: """ XDR Source Code:: @@ -26,7 +25,6 @@ class ContractEventBody: } v0; } """ - def __init__( self, v: int, @@ -34,7 +32,6 @@ def __init__( ) -> None: self.v = v self.v0 = v0 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v0 should not be None.") self.v0.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractEventBody: v = Integer.unpack(unpacker) @@ -50,7 +46,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractEventBody: v0 = ContractEventV0.unpack(unpacker) return cls(v=v, v0=v0) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,22 +64,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractEventBody: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v0, - ) - ) - + return hash((self.v, self.v0,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v0 == other.v0 - + return self.v== other.v and self.v0== other.v0 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v0={self.v0}") if self.v0 is not None else None + out.append(f'v={self.v}') + out.append(f'v0={self.v0}') if self.v0 is not None else None return f"" diff --git a/stellar_sdk/xdr/contract_event_type.py b/stellar_sdk/xdr/contract_event_type.py index 2175ba44..37773b23 100644 --- a/stellar_sdk/xdr/contract_event_type.py +++ b/stellar_sdk/xdr/contract_event_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ContractEventType"] - - +__all__ = ['ContractEventType'] class ContractEventType(IntEnum): """ XDR Source Code:: @@ -21,11 +21,9 @@ class ContractEventType(IntEnum): DIAGNOSTIC = 2 }; """ - SYSTEM = 0 CONTRACT = 1 DIAGNOSTIC = 2 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -33,7 +31,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ContractEventType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/contract_event_v0.py b/stellar_sdk/xdr/contract_event_v0.py index 37da76f6..6deb790c 100644 --- a/stellar_sdk/xdr/contract_event_v0.py +++ b/stellar_sdk/xdr/contract_event_v0.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_val import SCVal - -__all__ = ["ContractEventV0"] - - +from .sc_val import SCVal +__all__ = ['ContractEventV0'] class ContractEventV0: """ XDR Source Code:: @@ -22,7 +22,6 @@ class ContractEventV0: SCVal data; } """ - def __init__( self, topics: List[SCVal], @@ -30,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if topics and len(topics) > _expect_max_length: - raise ValueError( - f"The maximum length of `topics` should be {_expect_max_length}, but got {len(topics)}." - ) + raise ValueError(f"The maximum length of `topics` should be {_expect_max_length}, but got {len(topics)}.") self.topics = topics self.data = data - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.topics)) for topics_item in self.topics: topics_item.pack(packer) self.data.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractEventV0: length = unpacker.unpack_uint() @@ -53,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractEventV0: topics=topics, data=data, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -72,23 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractEventV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.topics, - self.data, - ) - ) - + return hash((self.topics, self.data,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.topics == other.topics and self.data == other.data - + return self.topics== other.topics and self.data== other.data def __str__(self): out = [ - f"topics={self.topics}", - f"data={self.data}", + f'topics={self.topics}', + f'data={self.data}', ] return f"" diff --git a/stellar_sdk/xdr/contract_executable.py b/stellar_sdk/xdr/contract_executable.py index f324c491..ea8bac0c 100644 --- a/stellar_sdk/xdr/contract_executable.py +++ b/stellar_sdk/xdr/contract_executable.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .contract_executable_type import ContractExecutableType from .hash import Hash - -__all__ = ["ContractExecutable"] - - +__all__ = ['ContractExecutable'] class ContractExecutable: """ XDR Source Code:: @@ -24,7 +24,6 @@ class ContractExecutable: void; }; """ - def __init__( self, type: ContractExecutableType, @@ -32,7 +31,6 @@ def __init__( ) -> None: self.type = type self.wasm_hash = wasm_hash - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == ContractExecutableType.CONTRACT_EXECUTABLE_WASM: @@ -42,7 +40,6 @@ def pack(self, packer: Packer) -> None: return if self.type == ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractExecutable: type = ContractExecutableType.unpack(unpacker) @@ -52,7 +49,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractExecutable: if type == ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN: return cls(type=type) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,24 +67,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractExecutable: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.wasm_hash, - ) - ) - + return hash((self.type, self.wasm_hash,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.type == other.type and self.wasm_hash == other.wasm_hash - + return self.type== other.type and self.wasm_hash== other.wasm_hash def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"wasm_hash={self.wasm_hash}" - ) if self.wasm_hash is not None else None + out.append(f'type={self.type}') + out.append(f'wasm_hash={self.wasm_hash}') if self.wasm_hash is not None else None return f"" diff --git a/stellar_sdk/xdr/contract_executable_type.py b/stellar_sdk/xdr/contract_executable_type.py index 7619af81..6a9ce5db 100644 --- a/stellar_sdk/xdr/contract_executable_type.py +++ b/stellar_sdk/xdr/contract_executable_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ContractExecutableType"] - - +__all__ = ['ContractExecutableType'] class ContractExecutableType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class ContractExecutableType(IntEnum): CONTRACT_EXECUTABLE_TOKEN = 1 }; """ - CONTRACT_EXECUTABLE_WASM = 0 CONTRACT_EXECUTABLE_TOKEN = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ContractExecutableType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/contract_id_preimage.py b/stellar_sdk/xdr/contract_id_preimage.py index 24f2031a..5cff2a14 100644 --- a/stellar_sdk/xdr/contract_id_preimage.py +++ b/stellar_sdk/xdr/contract_id_preimage.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .asset import Asset -from .contract_id_preimage_from_address import ContractIDPreimageFromAddress from .contract_id_preimage_type import ContractIDPreimageType - -__all__ = ["ContractIDPreimage"] - - +from .contract_id_preimage_from_address import ContractIDPreimageFromAddress +from .asset import Asset +__all__ = ['ContractIDPreimage'] class ContractIDPreimage: """ XDR Source Code:: @@ -29,7 +29,6 @@ class ContractIDPreimage: Asset fromAsset; }; """ - def __init__( self, type: ContractIDPreimageType, @@ -39,7 +38,6 @@ def __init__( self.type = type self.from_address = from_address self.from_asset = from_asset - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS: @@ -52,7 +50,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("from_asset should not be None.") self.from_asset.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractIDPreimage: type = ContractIDPreimageType.unpack(unpacker) @@ -63,7 +60,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractIDPreimage: from_asset = Asset.unpack(unpacker) return cls(type=type, from_asset=from_asset) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -82,32 +78,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractIDPreimage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.from_address, - self.from_asset, - ) - ) - + return hash((self.type, self.from_address, self.from_asset,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.from_address == other.from_address - and self.from_asset == other.from_asset - ) - + return self.type== other.type and self.from_address== other.from_address and self.from_asset== other.from_asset def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"from_address={self.from_address}" - ) if self.from_address is not None else None - out.append( - f"from_asset={self.from_asset}" - ) if self.from_asset is not None else None + out.append(f'type={self.type}') + out.append(f'from_address={self.from_address}') if self.from_address is not None else None + out.append(f'from_asset={self.from_asset}') if self.from_asset is not None else None return f"" diff --git a/stellar_sdk/xdr/contract_id_preimage_from_address.py b/stellar_sdk/xdr/contract_id_preimage_from_address.py index 2a06df0b..59eba33a 100644 --- a/stellar_sdk/xdr/contract_id_preimage_from_address.py +++ b/stellar_sdk/xdr/contract_id_preimage_from_address.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_address import SCAddress from .uint256 import Uint256 - -__all__ = ["ContractIDPreimageFromAddress"] - - +__all__ = ['ContractIDPreimageFromAddress'] class ContractIDPreimageFromAddress: """ XDR Source Code:: @@ -22,7 +22,6 @@ class ContractIDPreimageFromAddress: uint256 salt; } """ - def __init__( self, address: SCAddress, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.address = address self.salt = salt - def pack(self, packer: Packer) -> None: self.address.pack(packer) self.salt.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ContractIDPreimageFromAddress: address = SCAddress.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> ContractIDPreimageFromAddress: address=address, salt=salt, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ContractIDPreimageFromAddress: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.address, - self.salt, - ) - ) - + return hash((self.address, self.salt,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.address == other.address and self.salt == other.salt - + return self.address== other.address and self.salt== other.salt def __str__(self): out = [ - f"address={self.address}", - f"salt={self.salt}", + f'address={self.address}', + f'salt={self.salt}', ] return f"" diff --git a/stellar_sdk/xdr/contract_id_preimage_type.py b/stellar_sdk/xdr/contract_id_preimage_type.py index 415eabf7..f3742165 100644 --- a/stellar_sdk/xdr/contract_id_preimage_type.py +++ b/stellar_sdk/xdr/contract_id_preimage_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ContractIDPreimageType"] - - +__all__ = ['ContractIDPreimageType'] class ContractIDPreimageType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class ContractIDPreimageType(IntEnum): CONTRACT_ID_PREIMAGE_FROM_ASSET = 1 }; """ - CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0 CONTRACT_ID_PREIMAGE_FROM_ASSET = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ContractIDPreimageType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/create_account_op.py b/stellar_sdk/xdr/create_account_op.py index fa9df0df..6cd99464 100644 --- a/stellar_sdk/xdr/create_account_op.py +++ b/stellar_sdk/xdr/create_account_op.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .int64 import Int64 - -__all__ = ["CreateAccountOp"] - - +__all__ = ['CreateAccountOp'] class CreateAccountOp: """ XDR Source Code:: @@ -22,7 +22,6 @@ class CreateAccountOp: int64 startingBalance; // amount they end up with }; """ - def __init__( self, destination: AccountID, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.destination = destination self.starting_balance = starting_balance - def pack(self, packer: Packer) -> None: self.destination.pack(packer) self.starting_balance.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> CreateAccountOp: destination = AccountID.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> CreateAccountOp: destination=destination, starting_balance=starting_balance, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> CreateAccountOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.destination, - self.starting_balance, - ) - ) - + return hash((self.destination, self.starting_balance,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.destination == other.destination - and self.starting_balance == other.starting_balance - ) - + return self.destination== other.destination and self.starting_balance== other.starting_balance def __str__(self): out = [ - f"destination={self.destination}", - f"starting_balance={self.starting_balance}", + f'destination={self.destination}', + f'starting_balance={self.starting_balance}', ] return f"" diff --git a/stellar_sdk/xdr/create_account_result.py b/stellar_sdk/xdr/create_account_result.py index 38f46f2f..57d08609 100644 --- a/stellar_sdk/xdr/create_account_result.py +++ b/stellar_sdk/xdr/create_account_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .create_account_result_code import CreateAccountResultCode - -__all__ = ["CreateAccountResult"] - - +__all__ = ['CreateAccountResult'] class CreateAccountResult: """ XDR Source Code:: @@ -26,13 +26,11 @@ class CreateAccountResult: void; }; """ - def __init__( self, code: CreateAccountResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == CreateAccountResultCode.CREATE_ACCOUNT_SUCCESS: @@ -45,7 +43,6 @@ def pack(self, packer: Packer) -> None: return if self.code == CreateAccountResultCode.CREATE_ACCOUNT_ALREADY_EXIST: return - @classmethod def unpack(cls, unpacker: Unpacker) -> CreateAccountResult: code = CreateAccountResultCode.unpack(unpacker) @@ -60,7 +57,6 @@ def unpack(cls, unpacker: Unpacker) -> CreateAccountResult: if code == CreateAccountResultCode.CREATE_ACCOUNT_ALREADY_EXIST: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -79,16 +75,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> CreateAccountResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/create_account_result_code.py b/stellar_sdk/xdr/create_account_result_code.py index 1b1cb2cf..de11083d 100644 --- a/stellar_sdk/xdr/create_account_result_code.py +++ b/stellar_sdk/xdr/create_account_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["CreateAccountResultCode"] - - +__all__ = ['CreateAccountResultCode'] class CreateAccountResultCode(IntEnum): """ XDR Source Code:: @@ -27,13 +27,11 @@ class CreateAccountResultCode(IntEnum): CREATE_ACCOUNT_ALREADY_EXIST = -4 // account already exists }; """ - CREATE_ACCOUNT_SUCCESS = 0 CREATE_ACCOUNT_MALFORMED = -1 CREATE_ACCOUNT_UNDERFUNDED = -2 CREATE_ACCOUNT_LOW_RESERVE = -3 CREATE_ACCOUNT_ALREADY_EXIST = -4 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -41,7 +39,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> CreateAccountResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/create_claimable_balance_op.py b/stellar_sdk/xdr/create_claimable_balance_op.py index 78ee4a82..9edfb99f 100644 --- a/stellar_sdk/xdr/create_claimable_balance_op.py +++ b/stellar_sdk/xdr/create_claimable_balance_op.py @@ -3,17 +3,16 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .asset import Asset -from .claimant import Claimant from .int64 import Int64 - -__all__ = ["CreateClaimableBalanceOp"] - - +from .claimant import Claimant +__all__ = ['CreateClaimableBalanceOp'] class CreateClaimableBalanceOp: """ XDR Source Code:: @@ -25,7 +24,6 @@ class CreateClaimableBalanceOp: Claimant claimants<10>; }; """ - def __init__( self, asset: Asset, @@ -34,20 +32,16 @@ def __init__( ) -> None: _expect_max_length = 10 if claimants and len(claimants) > _expect_max_length: - raise ValueError( - f"The maximum length of `claimants` should be {_expect_max_length}, but got {len(claimants)}." - ) + raise ValueError(f"The maximum length of `claimants` should be {_expect_max_length}, but got {len(claimants)}.") self.asset = asset self.amount = amount self.claimants = claimants - def pack(self, packer: Packer) -> None: self.asset.pack(packer) self.amount.pack(packer) packer.pack_uint(len(self.claimants)) for claimants_item in self.claimants: claimants_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> CreateClaimableBalanceOp: asset = Asset.unpack(unpacker) @@ -61,7 +55,6 @@ def unpack(cls, unpacker: Unpacker) -> CreateClaimableBalanceOp: amount=amount, claimants=claimants, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -80,29 +73,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> CreateClaimableBalanceOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.asset, - self.amount, - self.claimants, - ) - ) - + return hash((self.asset, self.amount, self.claimants,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.asset == other.asset - and self.amount == other.amount - and self.claimants == other.claimants - ) - + return self.asset== other.asset and self.amount== other.amount and self.claimants== other.claimants def __str__(self): out = [ - f"asset={self.asset}", - f"amount={self.amount}", - f"claimants={self.claimants}", + f'asset={self.asset}', + f'amount={self.amount}', + f'claimants={self.claimants}', ] return f"" diff --git a/stellar_sdk/xdr/create_claimable_balance_result.py b/stellar_sdk/xdr/create_claimable_balance_result.py index 18a838e1..b324e023 100644 --- a/stellar_sdk/xdr/create_claimable_balance_result.py +++ b/stellar_sdk/xdr/create_claimable_balance_result.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .claimable_balance_id import ClaimableBalanceID from .create_claimable_balance_result_code import CreateClaimableBalanceResultCode - -__all__ = ["CreateClaimableBalanceResult"] - - +from .claimable_balance_id import ClaimableBalanceID +__all__ = ['CreateClaimableBalanceResult'] class CreateClaimableBalanceResult: """ XDR Source Code:: @@ -29,7 +29,6 @@ class CreateClaimableBalanceResult: void; }; """ - def __init__( self, code: CreateClaimableBalanceResultCode, @@ -37,43 +36,23 @@ def __init__( ) -> None: self.code = code self.balance_id = balance_id - def pack(self, packer: Packer) -> None: self.code.pack(packer) - if ( - self.code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_SUCCESS - ): + if self.code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_SUCCESS: if self.balance_id is None: raise ValueError("balance_id should not be None.") self.balance_id.pack(packer) return - if ( - self.code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_MALFORMED - ): + if self.code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_MALFORMED: return - if ( - self.code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_LOW_RESERVE - ): + if self.code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_LOW_RESERVE: return - if ( - self.code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_NO_TRUST - ): + if self.code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_NO_TRUST: return - if ( - self.code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED - ): + if self.code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED: return - if ( - self.code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_UNDERFUNDED - ): + if self.code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_UNDERFUNDED: return - @classmethod def unpack(cls, unpacker: Unpacker) -> CreateClaimableBalanceResult: code = CreateClaimableBalanceResultCode.unpack(unpacker) @@ -82,25 +61,15 @@ def unpack(cls, unpacker: Unpacker) -> CreateClaimableBalanceResult: return cls(code=code, balance_id=balance_id) if code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_MALFORMED: return cls(code=code) - if ( - code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_LOW_RESERVE - ): + if code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_LOW_RESERVE: return cls(code=code) if code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_NO_TRUST: return cls(code=code) - if ( - code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED - ): + if code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED: return cls(code=code) - if ( - code - == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_UNDERFUNDED - ): + if code == CreateClaimableBalanceResultCode.CREATE_CLAIMABLE_BALANCE_UNDERFUNDED: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -119,24 +88,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> CreateClaimableBalanceResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.balance_id, - ) - ) - + return hash((self.code, self.balance_id,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code and self.balance_id == other.balance_id - + return self.code== other.code and self.balance_id== other.balance_id def __str__(self): out = [] - out.append(f"code={self.code}") - out.append( - f"balance_id={self.balance_id}" - ) if self.balance_id is not None else None + out.append(f'code={self.code}') + out.append(f'balance_id={self.balance_id}') if self.balance_id is not None else None return f"" diff --git a/stellar_sdk/xdr/create_claimable_balance_result_code.py b/stellar_sdk/xdr/create_claimable_balance_result_code.py index bfcc233a..d1f0f51a 100644 --- a/stellar_sdk/xdr/create_claimable_balance_result_code.py +++ b/stellar_sdk/xdr/create_claimable_balance_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["CreateClaimableBalanceResultCode"] - - +__all__ = ['CreateClaimableBalanceResultCode'] class CreateClaimableBalanceResultCode(IntEnum): """ XDR Source Code:: @@ -24,14 +24,12 @@ class CreateClaimableBalanceResultCode(IntEnum): CREATE_CLAIMABLE_BALANCE_UNDERFUNDED = -5 }; """ - CREATE_CLAIMABLE_BALANCE_SUCCESS = 0 CREATE_CLAIMABLE_BALANCE_MALFORMED = -1 CREATE_CLAIMABLE_BALANCE_LOW_RESERVE = -2 CREATE_CLAIMABLE_BALANCE_NO_TRUST = -3 CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED = -4 CREATE_CLAIMABLE_BALANCE_UNDERFUNDED = -5 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -39,7 +37,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> CreateClaimableBalanceResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/create_contract_args.py b/stellar_sdk/xdr/create_contract_args.py index df8cd36e..b9fa3df8 100644 --- a/stellar_sdk/xdr/create_contract_args.py +++ b/stellar_sdk/xdr/create_contract_args.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .contract_executable import ContractExecutable from .contract_id_preimage import ContractIDPreimage - -__all__ = ["CreateContractArgs"] - - +from .contract_executable import ContractExecutable +__all__ = ['CreateContractArgs'] class CreateContractArgs: """ XDR Source Code:: @@ -22,7 +22,6 @@ class CreateContractArgs: ContractExecutable executable; }; """ - def __init__( self, contract_id_preimage: ContractIDPreimage, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.contract_id_preimage = contract_id_preimage self.executable = executable - def pack(self, packer: Packer) -> None: self.contract_id_preimage.pack(packer) self.executable.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> CreateContractArgs: contract_id_preimage = ContractIDPreimage.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> CreateContractArgs: contract_id_preimage=contract_id_preimage, executable=executable, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> CreateContractArgs: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.contract_id_preimage, - self.executable, - ) - ) - + return hash((self.contract_id_preimage, self.executable,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.contract_id_preimage == other.contract_id_preimage - and self.executable == other.executable - ) - + return self.contract_id_preimage== other.contract_id_preimage and self.executable== other.executable def __str__(self): out = [ - f"contract_id_preimage={self.contract_id_preimage}", - f"executable={self.executable}", + f'contract_id_preimage={self.contract_id_preimage}', + f'executable={self.executable}', ] return f"" diff --git a/stellar_sdk/xdr/create_passive_sell_offer_op.py b/stellar_sdk/xdr/create_passive_sell_offer_op.py index fcfadf61..3f989ab5 100644 --- a/stellar_sdk/xdr/create_passive_sell_offer_op.py +++ b/stellar_sdk/xdr/create_passive_sell_offer_op.py @@ -3,16 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .asset import Asset from .asset import Asset from .int64 import Int64 from .price import Price - -__all__ = ["CreatePassiveSellOfferOp"] - - +__all__ = ['CreatePassiveSellOfferOp'] class CreatePassiveSellOfferOp: """ XDR Source Code:: @@ -25,7 +26,6 @@ class CreatePassiveSellOfferOp: Price price; // cost of A in terms of B }; """ - def __init__( self, selling: Asset, @@ -37,13 +37,11 @@ def __init__( self.buying = buying self.amount = amount self.price = price - def pack(self, packer: Packer) -> None: self.selling.pack(packer) self.buying.pack(packer) self.amount.pack(packer) self.price.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> CreatePassiveSellOfferOp: selling = Asset.unpack(unpacker) @@ -56,7 +54,6 @@ def unpack(cls, unpacker: Unpacker) -> CreatePassiveSellOfferOp: amount=amount, price=price, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -75,32 +72,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> CreatePassiveSellOfferOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.selling, - self.buying, - self.amount, - self.price, - ) - ) - + return hash((self.selling, self.buying, self.amount, self.price,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.selling == other.selling - and self.buying == other.buying - and self.amount == other.amount - and self.price == other.price - ) - + return self.selling== other.selling and self.buying== other.buying and self.amount== other.amount and self.price== other.price def __str__(self): out = [ - f"selling={self.selling}", - f"buying={self.buying}", - f"amount={self.amount}", - f"price={self.price}", + f'selling={self.selling}', + f'buying={self.buying}', + f'amount={self.amount}', + f'price={self.price}', ] return f"" diff --git a/stellar_sdk/xdr/crypto_key_type.py b/stellar_sdk/xdr/crypto_key_type.py index 47b8dd3b..62e77767 100644 --- a/stellar_sdk/xdr/crypto_key_type.py +++ b/stellar_sdk/xdr/crypto_key_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["CryptoKeyType"] - - +__all__ = ['CryptoKeyType'] class CryptoKeyType(IntEnum): """ XDR Source Code:: @@ -25,13 +25,11 @@ class CryptoKeyType(IntEnum): KEY_TYPE_MUXED_ED25519 = 0x100 }; """ - KEY_TYPE_ED25519 = 0 KEY_TYPE_PRE_AUTH_TX = 1 KEY_TYPE_HASH_X = 2 KEY_TYPE_ED25519_SIGNED_PAYLOAD = 3 KEY_TYPE_MUXED_ED25519 = 256 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -39,7 +37,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> CryptoKeyType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/curve25519_public.py b/stellar_sdk/xdr/curve25519_public.py index c8b902e0..5c8609a1 100644 --- a/stellar_sdk/xdr/curve25519_public.py +++ b/stellar_sdk/xdr/curve25519_public.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["Curve25519Public"] - - +__all__ = ['Curve25519Public'] class Curve25519Public: """ XDR Source Code:: @@ -20,23 +19,19 @@ class Curve25519Public: opaque key[32]; }; """ - def __init__( self, key: bytes, ) -> None: self.key = key - def pack(self, packer: Packer) -> None: Opaque(self.key, 32, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Curve25519Public: key = Opaque.unpack(unpacker, 32, True) return cls( key=key, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +50,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Curve25519Public: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.key,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.key == other.key - + return self.key== other.key def __str__(self): out = [ - f"key={self.key}", + f'key={self.key}', ] return f"" diff --git a/stellar_sdk/xdr/curve25519_secret.py b/stellar_sdk/xdr/curve25519_secret.py index 53087b60..5c3660a2 100644 --- a/stellar_sdk/xdr/curve25519_secret.py +++ b/stellar_sdk/xdr/curve25519_secret.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["Curve25519Secret"] - - +__all__ = ['Curve25519Secret'] class Curve25519Secret: """ XDR Source Code:: @@ -20,23 +19,19 @@ class Curve25519Secret: opaque key[32]; }; """ - def __init__( self, key: bytes, ) -> None: self.key = key - def pack(self, packer: Packer) -> None: Opaque(self.key, 32, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Curve25519Secret: key = Opaque.unpack(unpacker, 32, True) return cls( key=key, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +50,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Curve25519Secret: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.key,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.key == other.key - + return self.key== other.key def __str__(self): out = [ - f"key={self.key}", + f'key={self.key}', ] return f"" diff --git a/stellar_sdk/xdr/data_entry.py b/stellar_sdk/xdr/data_entry.py index 8ba863ca..36e962cc 100644 --- a/stellar_sdk/xdr/data_entry.py +++ b/stellar_sdk/xdr/data_entry.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID -from .data_entry_ext import DataEntryExt -from .data_value import DataValue from .string64 import String64 - -__all__ = ["DataEntry"] - - +from .data_value import DataValue +from .data_entry_ext import DataEntryExt +__all__ = ['DataEntry'] class DataEntry: """ XDR Source Code:: @@ -33,7 +33,6 @@ class DataEntry: ext; }; """ - def __init__( self, account_id: AccountID, @@ -45,13 +44,11 @@ def __init__( self.data_name = data_name self.data_value = data_value self.ext = ext - def pack(self, packer: Packer) -> None: self.account_id.pack(packer) self.data_name.pack(packer) self.data_value.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> DataEntry: account_id = AccountID.unpack(unpacker) @@ -64,7 +61,6 @@ def unpack(cls, unpacker: Unpacker) -> DataEntry: data_value=data_value, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -83,32 +79,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> DataEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.account_id, - self.data_name, - self.data_value, - self.ext, - ) - ) - + return hash((self.account_id, self.data_name, self.data_value, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.account_id == other.account_id - and self.data_name == other.data_name - and self.data_value == other.data_value - and self.ext == other.ext - ) - + return self.account_id== other.account_id and self.data_name== other.data_name and self.data_value== other.data_value and self.ext== other.ext def __str__(self): out = [ - f"account_id={self.account_id}", - f"data_name={self.data_name}", - f"data_value={self.data_value}", - f"ext={self.ext}", + f'account_id={self.account_id}', + f'data_name={self.data_name}', + f'data_value={self.data_value}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/data_entry_ext.py b/stellar_sdk/xdr/data_entry_ext.py index d2e86e66..90e66a68 100644 --- a/stellar_sdk/xdr/data_entry_ext.py +++ b/stellar_sdk/xdr/data_entry_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["DataEntryExt"] - - +__all__ = ['DataEntryExt'] class DataEntryExt: """ XDR Source Code:: @@ -21,25 +20,21 @@ class DataEntryExt: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> DataEntryExt: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> DataEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/data_value.py b/stellar_sdk/xdr/data_value.py index 64d2cef7..29e13402 100644 --- a/stellar_sdk/xdr/data_value.py +++ b/stellar_sdk/xdr/data_value.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["DataValue"] - - +__all__ = ['DataValue'] class DataValue: """ XDR Source Code:: typedef opaque DataValue<64>; """ - def __init__(self, data_value: bytes) -> None: self.data_value = data_value - def pack(self, packer: Packer) -> None: Opaque(self.data_value, 64, False).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> DataValue: data_value = Opaque.unpack(unpacker, 64, False) return cls(data_value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> DataValue: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.data_value) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/decorated_signature.py b/stellar_sdk/xdr/decorated_signature.py index b997b36a..be1e9935 100644 --- a/stellar_sdk/xdr/decorated_signature.py +++ b/stellar_sdk/xdr/decorated_signature.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .signature import Signature from .signature_hint import SignatureHint - -__all__ = ["DecoratedSignature"] - - +from .signature import Signature +__all__ = ['DecoratedSignature'] class DecoratedSignature: """ XDR Source Code:: @@ -22,7 +22,6 @@ class DecoratedSignature: Signature signature; // actual signature }; """ - def __init__( self, hint: SignatureHint, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.hint = hint self.signature = signature - def pack(self, packer: Packer) -> None: self.hint.pack(packer) self.signature.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> DecoratedSignature: hint = SignatureHint.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> DecoratedSignature: hint=hint, signature=signature, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> DecoratedSignature: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.hint, - self.signature, - ) - ) - + return hash((self.hint, self.signature,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.hint == other.hint and self.signature == other.signature - + return self.hint== other.hint and self.signature== other.signature def __str__(self): out = [ - f"hint={self.hint}", - f"signature={self.signature}", + f'hint={self.hint}', + f'signature={self.signature}', ] return f"" diff --git a/stellar_sdk/xdr/diagnostic_event.py b/stellar_sdk/xdr/diagnostic_event.py index dd1accf8..cac0971a 100644 --- a/stellar_sdk/xdr/diagnostic_event.py +++ b/stellar_sdk/xdr/diagnostic_event.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Boolean from .contract_event import ContractEvent - -__all__ = ["DiagnosticEvent"] - - +__all__ = ['DiagnosticEvent'] class DiagnosticEvent: """ XDR Source Code:: @@ -22,7 +21,6 @@ class DiagnosticEvent: ContractEvent event; }; """ - def __init__( self, in_successful_contract_call: bool, @@ -30,11 +28,9 @@ def __init__( ) -> None: self.in_successful_contract_call = in_successful_contract_call self.event = event - def pack(self, packer: Packer) -> None: Boolean(self.in_successful_contract_call).pack(packer) self.event.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> DiagnosticEvent: in_successful_contract_call = Boolean.unpack(unpacker) @@ -43,7 +39,6 @@ def unpack(cls, unpacker: Unpacker) -> DiagnosticEvent: in_successful_contract_call=in_successful_contract_call, event=event, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +57,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> DiagnosticEvent: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.in_successful_contract_call, - self.event, - ) - ) - + return hash((self.in_successful_contract_call, self.event,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.in_successful_contract_call == other.in_successful_contract_call - and self.event == other.event - ) - + return self.in_successful_contract_call== other.in_successful_contract_call and self.event== other.event def __str__(self): out = [ - f"in_successful_contract_call={self.in_successful_contract_call}", - f"event={self.event}", + f'in_successful_contract_call={self.in_successful_contract_call}', + f'event={self.event}', ] return f"" diff --git a/stellar_sdk/xdr/dont_have.py b/stellar_sdk/xdr/dont_have.py index c420b5c0..0eb1e8a6 100644 --- a/stellar_sdk/xdr/dont_have.py +++ b/stellar_sdk/xdr/dont_have.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .message_type import MessageType from .uint256 import Uint256 - -__all__ = ["DontHave"] - - +__all__ = ['DontHave'] class DontHave: """ XDR Source Code:: @@ -22,7 +22,6 @@ class DontHave: uint256 reqHash; }; """ - def __init__( self, type: MessageType, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.type = type self.req_hash = req_hash - def pack(self, packer: Packer) -> None: self.type.pack(packer) self.req_hash.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> DontHave: type = MessageType.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> DontHave: type=type, req_hash=req_hash, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> DontHave: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.req_hash, - ) - ) - + return hash((self.type, self.req_hash,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.type == other.type and self.req_hash == other.req_hash - + return self.type== other.type and self.req_hash== other.req_hash def __str__(self): out = [ - f"type={self.type}", - f"req_hash={self.req_hash}", + f'type={self.type}', + f'req_hash={self.req_hash}', ] return f"" diff --git a/stellar_sdk/xdr/duration.py b/stellar_sdk/xdr/duration.py index 4ea0bdd0..ee4f6f27 100644 --- a/stellar_sdk/xdr/duration.py +++ b/stellar_sdk/xdr/duration.py @@ -3,32 +3,28 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint64 import Uint64 - -__all__ = ["Duration"] - - +__all__ = ['Duration'] class Duration: """ XDR Source Code:: typedef uint64 Duration; """ - def __init__(self, duration: Uint64) -> None: self.duration = duration - def pack(self, packer: Packer) -> None: self.duration.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Duration: duration = Uint64.unpack(unpacker) return cls(duration) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +43,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Duration: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.duration) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/encrypted_body.py b/stellar_sdk/xdr/encrypted_body.py index 95aa7101..79642c83 100644 --- a/stellar_sdk/xdr/encrypted_body.py +++ b/stellar_sdk/xdr/encrypted_body.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["EncryptedBody"] - - +__all__ = ['EncryptedBody'] class EncryptedBody: """ XDR Source Code:: typedef opaque EncryptedBody<64000>; """ - def __init__(self, encrypted_body: bytes) -> None: self.encrypted_body = encrypted_body - def pack(self, packer: Packer) -> None: Opaque(self.encrypted_body, 64000, False).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> EncryptedBody: encrypted_body = Opaque.unpack(unpacker, 64000, False) return cls(encrypted_body) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> EncryptedBody: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.encrypted_body) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/end_sponsoring_future_reserves_result.py b/stellar_sdk/xdr/end_sponsoring_future_reserves_result.py index cb01d73b..02bced7b 100644 --- a/stellar_sdk/xdr/end_sponsoring_future_reserves_result.py +++ b/stellar_sdk/xdr/end_sponsoring_future_reserves_result.py @@ -3,16 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .end_sponsoring_future_reserves_result_code import ( - EndSponsoringFutureReservesResultCode, -) - -__all__ = ["EndSponsoringFutureReservesResult"] - - +from .end_sponsoring_future_reserves_result_code import EndSponsoringFutureReservesResultCode +__all__ = ['EndSponsoringFutureReservesResult'] class EndSponsoringFutureReservesResult: """ XDR Source Code:: @@ -26,41 +24,25 @@ class EndSponsoringFutureReservesResult: void; }; """ - def __init__( self, code: EndSponsoringFutureReservesResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) - if ( - self.code - == EndSponsoringFutureReservesResultCode.END_SPONSORING_FUTURE_RESERVES_SUCCESS - ): + if self.code == EndSponsoringFutureReservesResultCode.END_SPONSORING_FUTURE_RESERVES_SUCCESS: return - if ( - self.code - == EndSponsoringFutureReservesResultCode.END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED - ): + if self.code == EndSponsoringFutureReservesResultCode.END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED: return - @classmethod def unpack(cls, unpacker: Unpacker) -> EndSponsoringFutureReservesResult: code = EndSponsoringFutureReservesResultCode.unpack(unpacker) - if ( - code - == EndSponsoringFutureReservesResultCode.END_SPONSORING_FUTURE_RESERVES_SUCCESS - ): + if code == EndSponsoringFutureReservesResultCode.END_SPONSORING_FUTURE_RESERVES_SUCCESS: return cls(code=code) - if ( - code - == EndSponsoringFutureReservesResultCode.END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED - ): + if code == EndSponsoringFutureReservesResultCode.END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -79,16 +61,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> EndSponsoringFutureReservesResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/end_sponsoring_future_reserves_result_code.py b/stellar_sdk/xdr/end_sponsoring_future_reserves_result_code.py index 4d07a0c4..6b3c33f2 100644 --- a/stellar_sdk/xdr/end_sponsoring_future_reserves_result_code.py +++ b/stellar_sdk/xdr/end_sponsoring_future_reserves_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["EndSponsoringFutureReservesResultCode"] - - +__all__ = ['EndSponsoringFutureReservesResultCode'] class EndSponsoringFutureReservesResultCode(IntEnum): """ XDR Source Code:: @@ -23,10 +23,8 @@ class EndSponsoringFutureReservesResultCode(IntEnum): END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED = -1 }; """ - END_SPONSORING_FUTURE_RESERVES_SUCCESS = 0 END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED = -1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -34,7 +32,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> EndSponsoringFutureReservesResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/envelope_type.py b/stellar_sdk/xdr/envelope_type.py index 9959ead1..756832ce 100644 --- a/stellar_sdk/xdr/envelope_type.py +++ b/stellar_sdk/xdr/envelope_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["EnvelopeType"] - - +__all__ = ['EnvelopeType'] class EnvelopeType(IntEnum): """ XDR Source Code:: @@ -28,7 +28,6 @@ class EnvelopeType(IntEnum): ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9 }; """ - ENVELOPE_TYPE_TX_V0 = 0 ENVELOPE_TYPE_SCP = 1 ENVELOPE_TYPE_TX = 2 @@ -39,7 +38,6 @@ class EnvelopeType(IntEnum): ENVELOPE_TYPE_POOL_REVOKE_OP_ID = 7 ENVELOPE_TYPE_CONTRACT_ID = 8 ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -47,7 +45,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> EnvelopeType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/error.py b/stellar_sdk/xdr/error.py index 8e29da1b..94b6d43e 100644 --- a/stellar_sdk/xdr/error.py +++ b/stellar_sdk/xdr/error.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import String from .error_code import ErrorCode - -__all__ = ["Error"] - - +__all__ = ['Error'] class Error: """ XDR Source Code:: @@ -22,7 +21,6 @@ class Error: string msg<100>; }; """ - def __init__( self, code: ErrorCode, @@ -30,11 +28,9 @@ def __init__( ) -> None: self.code = code self.msg = msg - def pack(self, packer: Packer) -> None: self.code.pack(packer) String(self.msg, 100).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Error: code = ErrorCode.unpack(unpacker) @@ -43,7 +39,6 @@ def unpack(cls, unpacker: Unpacker) -> Error: code=code, msg=msg, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +57,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Error: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.msg, - ) - ) - + return hash((self.code, self.msg,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code and self.msg == other.msg - + return self.code== other.code and self.msg== other.msg def __str__(self): out = [ - f"code={self.code}", - f"msg={self.msg}", + f'code={self.code}', + f'msg={self.msg}', ] return f"" diff --git a/stellar_sdk/xdr/error_code.py b/stellar_sdk/xdr/error_code.py index 90962330..c7c734fe 100644 --- a/stellar_sdk/xdr/error_code.py +++ b/stellar_sdk/xdr/error_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ErrorCode"] - - +__all__ = ['ErrorCode'] class ErrorCode(IntEnum): """ XDR Source Code:: @@ -23,13 +23,11 @@ class ErrorCode(IntEnum): ERR_LOAD = 4 // System overloaded }; """ - ERR_MISC = 0 ERR_DATA = 1 ERR_CONF = 2 ERR_AUTH = 3 ERR_LOAD = 4 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -37,7 +35,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ErrorCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/eviction_iterator.py b/stellar_sdk/xdr/eviction_iterator.py new file mode 100644 index 00000000..928702e0 --- /dev/null +++ b/stellar_sdk/xdr/eviction_iterator.py @@ -0,0 +1,78 @@ +# This is an automatically generated file. +# DO NOT EDIT or your changes may be overwritten +from __future__ import annotations + +import base64 +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING +from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * + +from .uint32 import Uint32 +from .uint64 import Uint64 +__all__ = ['EvictionIterator'] +class EvictionIterator: + """ + XDR Source Code:: + + struct EvictionIterator { + uint32 bucketListLevel; + bool isCurrBucket; + uint64 bucketFileOffset; + }; + """ + def __init__( + self, + bucket_list_level: Uint32, + is_curr_bucket: bool, + bucket_file_offset: Uint64, + ) -> None: + self.bucket_list_level = bucket_list_level + self.is_curr_bucket = is_curr_bucket + self.bucket_file_offset = bucket_file_offset + def pack(self, packer: Packer) -> None: + self.bucket_list_level.pack(packer) + Boolean(self.is_curr_bucket).pack(packer) + self.bucket_file_offset.pack(packer) + @classmethod + def unpack(cls, unpacker: Unpacker) -> EvictionIterator: + bucket_list_level = Uint32.unpack(unpacker) + is_curr_bucket = Boolean.unpack(unpacker) + bucket_file_offset = Uint64.unpack(unpacker) + return cls( + bucket_list_level=bucket_list_level, + is_curr_bucket=is_curr_bucket, + bucket_file_offset=bucket_file_offset, + ) + def to_xdr_bytes(self) -> bytes: + packer = Packer() + self.pack(packer) + return packer.get_buffer() + + @classmethod + def from_xdr_bytes(cls, xdr: bytes) -> EvictionIterator: + unpacker = Unpacker(xdr) + return cls.unpack(unpacker) + + def to_xdr(self) -> str: + xdr_bytes = self.to_xdr_bytes() + return base64.b64encode(xdr_bytes).decode() + + @classmethod + def from_xdr(cls, xdr: str) -> EvictionIterator: + xdr_bytes = base64.b64decode(xdr.encode()) + return cls.from_xdr_bytes(xdr_bytes) + def __hash__(self): + return hash((self.bucket_list_level, self.is_curr_bucket, self.bucket_file_offset,)) + def __eq__(self, other: object): + if not isinstance(other, self.__class__): + return NotImplemented + return self.bucket_list_level== other.bucket_list_level and self.is_curr_bucket== other.is_curr_bucket and self.bucket_file_offset== other.bucket_file_offset + def __str__(self): + out = [ + f'bucket_list_level={self.bucket_list_level}', + f'is_curr_bucket={self.is_curr_bucket}', + f'bucket_file_offset={self.bucket_file_offset}', + ] + return f"" diff --git a/stellar_sdk/xdr/expiration_entry.py b/stellar_sdk/xdr/expiration_entry.py new file mode 100644 index 00000000..6bd59143 --- /dev/null +++ b/stellar_sdk/xdr/expiration_entry.py @@ -0,0 +1,72 @@ +# This is an automatically generated file. +# DO NOT EDIT or your changes may be overwritten +from __future__ import annotations + +import base64 +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING +from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * + +from .hash import Hash +from .uint32 import Uint32 +__all__ = ['ExpirationEntry'] +class ExpirationEntry: + """ + XDR Source Code:: + + struct ExpirationEntry { + // Hash of the LedgerKey that is associated with this ExpirationEntry + Hash keyHash; + uint32 expirationLedgerSeq; + }; + """ + def __init__( + self, + key_hash: Hash, + expiration_ledger_seq: Uint32, + ) -> None: + self.key_hash = key_hash + self.expiration_ledger_seq = expiration_ledger_seq + def pack(self, packer: Packer) -> None: + self.key_hash.pack(packer) + self.expiration_ledger_seq.pack(packer) + @classmethod + def unpack(cls, unpacker: Unpacker) -> ExpirationEntry: + key_hash = Hash.unpack(unpacker) + expiration_ledger_seq = Uint32.unpack(unpacker) + return cls( + key_hash=key_hash, + expiration_ledger_seq=expiration_ledger_seq, + ) + def to_xdr_bytes(self) -> bytes: + packer = Packer() + self.pack(packer) + return packer.get_buffer() + + @classmethod + def from_xdr_bytes(cls, xdr: bytes) -> ExpirationEntry: + unpacker = Unpacker(xdr) + return cls.unpack(unpacker) + + def to_xdr(self) -> str: + xdr_bytes = self.to_xdr_bytes() + return base64.b64encode(xdr_bytes).decode() + + @classmethod + def from_xdr(cls, xdr: str) -> ExpirationEntry: + xdr_bytes = base64.b64decode(xdr.encode()) + return cls.from_xdr_bytes(xdr_bytes) + def __hash__(self): + return hash((self.key_hash, self.expiration_ledger_seq,)) + def __eq__(self, other: object): + if not isinstance(other, self.__class__): + return NotImplemented + return self.key_hash== other.key_hash and self.expiration_ledger_seq== other.expiration_ledger_seq + def __str__(self): + out = [ + f'key_hash={self.key_hash}', + f'expiration_ledger_seq={self.expiration_ledger_seq}', + ] + return f"" diff --git a/stellar_sdk/xdr/extension_point.py b/stellar_sdk/xdr/extension_point.py index be4a343e..f6bc7826 100644 --- a/stellar_sdk/xdr/extension_point.py +++ b/stellar_sdk/xdr/extension_point.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["ExtensionPoint"] - - +__all__ = ['ExtensionPoint'] class ExtensionPoint: """ XDR Source Code:: @@ -21,25 +20,21 @@ class ExtensionPoint: void; }; """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ExtensionPoint: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ExtensionPoint: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/fee_bump_transaction.py b/stellar_sdk/xdr/fee_bump_transaction.py index bebc8b72..15251d1c 100644 --- a/stellar_sdk/xdr/fee_bump_transaction.py +++ b/stellar_sdk/xdr/fee_bump_transaction.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .fee_bump_transaction_ext import FeeBumpTransactionExt -from .fee_bump_transaction_inner_tx import FeeBumpTransactionInnerTx -from .int64 import Int64 from .muxed_account import MuxedAccount - -__all__ = ["FeeBumpTransaction"] - - +from .int64 import Int64 +from .fee_bump_transaction_inner_tx import FeeBumpTransactionInnerTx +from .fee_bump_transaction_ext import FeeBumpTransactionExt +__all__ = ['FeeBumpTransaction'] class FeeBumpTransaction: """ XDR Source Code:: @@ -36,7 +36,6 @@ class FeeBumpTransaction: ext; }; """ - def __init__( self, fee_source: MuxedAccount, @@ -48,13 +47,11 @@ def __init__( self.fee = fee self.inner_tx = inner_tx self.ext = ext - def pack(self, packer: Packer) -> None: self.fee_source.pack(packer) self.fee.pack(packer) self.inner_tx.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> FeeBumpTransaction: fee_source = MuxedAccount.unpack(unpacker) @@ -67,7 +64,6 @@ def unpack(cls, unpacker: Unpacker) -> FeeBumpTransaction: inner_tx=inner_tx, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -86,32 +82,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> FeeBumpTransaction: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.fee_source, - self.fee, - self.inner_tx, - self.ext, - ) - ) - + return hash((self.fee_source, self.fee, self.inner_tx, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.fee_source == other.fee_source - and self.fee == other.fee - and self.inner_tx == other.inner_tx - and self.ext == other.ext - ) - + return self.fee_source== other.fee_source and self.fee== other.fee and self.inner_tx== other.inner_tx and self.ext== other.ext def __str__(self): out = [ - f"fee_source={self.fee_source}", - f"fee={self.fee}", - f"inner_tx={self.inner_tx}", - f"ext={self.ext}", + f'fee_source={self.fee_source}', + f'fee={self.fee}', + f'inner_tx={self.inner_tx}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/fee_bump_transaction_envelope.py b/stellar_sdk/xdr/fee_bump_transaction_envelope.py index 892c7ff2..4931d6f1 100644 --- a/stellar_sdk/xdr/fee_bump_transaction_envelope.py +++ b/stellar_sdk/xdr/fee_bump_transaction_envelope.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .decorated_signature import DecoratedSignature from .fee_bump_transaction import FeeBumpTransaction - -__all__ = ["FeeBumpTransactionEnvelope"] - - +from .decorated_signature import DecoratedSignature +__all__ = ['FeeBumpTransactionEnvelope'] class FeeBumpTransactionEnvelope: """ XDR Source Code:: @@ -25,7 +24,6 @@ class FeeBumpTransactionEnvelope: DecoratedSignature signatures<20>; }; """ - def __init__( self, tx: FeeBumpTransaction, @@ -33,18 +31,14 @@ def __init__( ) -> None: _expect_max_length = 20 if signatures and len(signatures) > _expect_max_length: - raise ValueError( - f"The maximum length of `signatures` should be {_expect_max_length}, but got {len(signatures)}." - ) + raise ValueError(f"The maximum length of `signatures` should be {_expect_max_length}, but got {len(signatures)}.") self.tx = tx self.signatures = signatures - def pack(self, packer: Packer) -> None: self.tx.pack(packer) packer.pack_uint(len(self.signatures)) for signatures_item in self.signatures: signatures_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> FeeBumpTransactionEnvelope: tx = FeeBumpTransaction.unpack(unpacker) @@ -56,7 +50,6 @@ def unpack(cls, unpacker: Unpacker) -> FeeBumpTransactionEnvelope: tx=tx, signatures=signatures, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -75,23 +68,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> FeeBumpTransactionEnvelope: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.tx, - self.signatures, - ) - ) - + return hash((self.tx, self.signatures,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.tx == other.tx and self.signatures == other.signatures - + return self.tx== other.tx and self.signatures== other.signatures def __str__(self): out = [ - f"tx={self.tx}", - f"signatures={self.signatures}", + f'tx={self.tx}', + f'signatures={self.signatures}', ] return f"" diff --git a/stellar_sdk/xdr/fee_bump_transaction_ext.py b/stellar_sdk/xdr/fee_bump_transaction_ext.py index 5bbb7079..2ffee2e4 100644 --- a/stellar_sdk/xdr/fee_bump_transaction_ext.py +++ b/stellar_sdk/xdr/fee_bump_transaction_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["FeeBumpTransactionExt"] - - +__all__ = ['FeeBumpTransactionExt'] class FeeBumpTransactionExt: """ XDR Source Code:: @@ -21,25 +20,21 @@ class FeeBumpTransactionExt: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> FeeBumpTransactionExt: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> FeeBumpTransactionExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/fee_bump_transaction_inner_tx.py b/stellar_sdk/xdr/fee_bump_transaction_inner_tx.py index af0d9151..e4f961a1 100644 --- a/stellar_sdk/xdr/fee_bump_transaction_inner_tx.py +++ b/stellar_sdk/xdr/fee_bump_transaction_inner_tx.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .envelope_type import EnvelopeType from .transaction_v1_envelope import TransactionV1Envelope - -__all__ = ["FeeBumpTransactionInnerTx"] - - +__all__ = ['FeeBumpTransactionInnerTx'] class FeeBumpTransactionInnerTx: """ XDR Source Code:: @@ -22,7 +22,6 @@ class FeeBumpTransactionInnerTx: TransactionV1Envelope v1; } """ - def __init__( self, type: EnvelopeType, @@ -30,7 +29,6 @@ def __init__( ) -> None: self.type = type self.v1 = v1 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == EnvelopeType.ENVELOPE_TYPE_TX: @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v1 should not be None.") self.v1.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> FeeBumpTransactionInnerTx: type = EnvelopeType.unpack(unpacker) @@ -46,7 +43,6 @@ def unpack(cls, unpacker: Unpacker) -> FeeBumpTransactionInnerTx: v1 = TransactionV1Envelope.unpack(unpacker) return cls(type=type, v1=v1) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -65,22 +61,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> FeeBumpTransactionInnerTx: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.v1, - ) - ) - + return hash((self.type, self.v1,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.type == other.type and self.v1 == other.v1 - + return self.type== other.type and self.v1== other.v1 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"v1={self.v1}") if self.v1 is not None else None + out.append(f'type={self.type}') + out.append(f'v1={self.v1}') if self.v1 is not None else None return f"" diff --git a/stellar_sdk/xdr/flood_advert.py b/stellar_sdk/xdr/flood_advert.py index ece034b9..1240670c 100644 --- a/stellar_sdk/xdr/flood_advert.py +++ b/stellar_sdk/xdr/flood_advert.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .tx_advert_vector import TxAdvertVector - -__all__ = ["FloodAdvert"] - - +__all__ = ['FloodAdvert'] class FloodAdvert: """ XDR Source Code:: @@ -20,23 +20,19 @@ class FloodAdvert: TxAdvertVector txHashes; }; """ - def __init__( self, tx_hashes: TxAdvertVector, ) -> None: self.tx_hashes = tx_hashes - def pack(self, packer: Packer) -> None: self.tx_hashes.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> FloodAdvert: tx_hashes = TxAdvertVector.unpack(unpacker) return cls( tx_hashes=tx_hashes, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> FloodAdvert: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.tx_hashes,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.tx_hashes == other.tx_hashes - + return self.tx_hashes== other.tx_hashes def __str__(self): out = [ - f"tx_hashes={self.tx_hashes}", + f'tx_hashes={self.tx_hashes}', ] return f"" diff --git a/stellar_sdk/xdr/flood_demand.py b/stellar_sdk/xdr/flood_demand.py index 0d9f1b66..d6fd07df 100644 --- a/stellar_sdk/xdr/flood_demand.py +++ b/stellar_sdk/xdr/flood_demand.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .tx_demand_vector import TxDemandVector - -__all__ = ["FloodDemand"] - - +__all__ = ['FloodDemand'] class FloodDemand: """ XDR Source Code:: @@ -20,23 +20,19 @@ class FloodDemand: TxDemandVector txHashes; }; """ - def __init__( self, tx_hashes: TxDemandVector, ) -> None: self.tx_hashes = tx_hashes - def pack(self, packer: Packer) -> None: self.tx_hashes.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> FloodDemand: tx_hashes = TxDemandVector.unpack(unpacker) return cls( tx_hashes=tx_hashes, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> FloodDemand: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.tx_hashes,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.tx_hashes == other.tx_hashes - + return self.tx_hashes== other.tx_hashes def __str__(self): out = [ - f"tx_hashes={self.tx_hashes}", + f'tx_hashes={self.tx_hashes}', ] return f"" diff --git a/stellar_sdk/xdr/generalized_transaction_set.py b/stellar_sdk/xdr/generalized_transaction_set.py index c1908798..8f729181 100644 --- a/stellar_sdk/xdr/generalized_transaction_set.py +++ b/stellar_sdk/xdr/generalized_transaction_set.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .transaction_set_v1 import TransactionSetV1 - -__all__ = ["GeneralizedTransactionSet"] - - +__all__ = ['GeneralizedTransactionSet'] class GeneralizedTransactionSet: """ XDR Source Code:: @@ -23,7 +22,6 @@ class GeneralizedTransactionSet: TransactionSetV1 v1TxSet; }; """ - def __init__( self, v: int, @@ -31,7 +29,6 @@ def __init__( ) -> None: self.v = v self.v1_tx_set = v1_tx_set - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 1: @@ -39,7 +36,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v1_tx_set should not be None.") self.v1_tx_set.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> GeneralizedTransactionSet: v = Integer.unpack(unpacker) @@ -47,7 +43,6 @@ def unpack(cls, unpacker: Unpacker) -> GeneralizedTransactionSet: v1_tx_set = TransactionSetV1.unpack(unpacker) return cls(v=v, v1_tx_set=v1_tx_set) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -66,24 +61,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> GeneralizedTransactionSet: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v1_tx_set, - ) - ) - + return hash((self.v, self.v1_tx_set,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v1_tx_set == other.v1_tx_set - + return self.v== other.v and self.v1_tx_set== other.v1_tx_set def __str__(self): out = [] - out.append(f"v={self.v}") - out.append( - f"v1_tx_set={self.v1_tx_set}" - ) if self.v1_tx_set is not None else None + out.append(f'v={self.v}') + out.append(f'v1_tx_set={self.v1_tx_set}') if self.v1_tx_set is not None else None return f"" diff --git a/stellar_sdk/xdr/hash.py b/stellar_sdk/xdr/hash.py index f7e17215..e4f98a72 100644 --- a/stellar_sdk/xdr/hash.py +++ b/stellar_sdk/xdr/hash.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["Hash"] - - +__all__ = ['Hash'] class Hash: """ XDR Source Code:: typedef opaque Hash[32]; """ - def __init__(self, hash: bytes) -> None: self.hash = hash - def pack(self, packer: Packer) -> None: Opaque(self.hash, 32, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Hash: hash = Opaque.unpack(unpacker, 32, True) return cls(hash) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Hash: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.hash) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/hash_id_preimage.py b/stellar_sdk/xdr/hash_id_preimage.py index 8ba0d626..50e6ba72 100644 --- a/stellar_sdk/xdr/hash_id_preimage.py +++ b/stellar_sdk/xdr/hash_id_preimage.py @@ -3,18 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .envelope_type import EnvelopeType -from .hash_id_preimage_contract_id import HashIDPreimageContractID from .hash_id_preimage_operation_id import HashIDPreimageOperationID from .hash_id_preimage_revoke_id import HashIDPreimageRevokeID +from .hash_id_preimage_contract_id import HashIDPreimageContractID from .hash_id_preimage_soroban_authorization import HashIDPreimageSorobanAuthorization - -__all__ = ["HashIDPreimage"] - - +__all__ = ['HashIDPreimage'] class HashIDPreimage: """ XDR Source Code:: @@ -32,7 +32,7 @@ class HashIDPreimage: struct { AccountID sourceAccount; - SequenceNumber seqNum; + SequenceNumber seqNum; uint32 opNum; PoolID liquidityPoolID; Asset asset; @@ -53,7 +53,6 @@ class HashIDPreimage: } sorobanAuthorization; }; """ - def __init__( self, type: EnvelopeType, @@ -67,7 +66,6 @@ def __init__( self.revoke_id = revoke_id self.contract_id = contract_id self.soroban_authorization = soroban_authorization - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == EnvelopeType.ENVELOPE_TYPE_OP_ID: @@ -90,7 +88,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("soroban_authorization should not be None.") self.soroban_authorization.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> HashIDPreimage: type = EnvelopeType.unpack(unpacker) @@ -107,7 +104,6 @@ def unpack(cls, unpacker: Unpacker) -> HashIDPreimage: soroban_authorization = HashIDPreimageSorobanAuthorization.unpack(unpacker) return cls(type=type, soroban_authorization=soroban_authorization) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -126,42 +122,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> HashIDPreimage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.operation_id, - self.revoke_id, - self.contract_id, - self.soroban_authorization, - ) - ) - + return hash((self.type, self.operation_id, self.revoke_id, self.contract_id, self.soroban_authorization,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.operation_id == other.operation_id - and self.revoke_id == other.revoke_id - and self.contract_id == other.contract_id - and self.soroban_authorization == other.soroban_authorization - ) - + return self.type== other.type and self.operation_id== other.operation_id and self.revoke_id== other.revoke_id and self.contract_id== other.contract_id and self.soroban_authorization== other.soroban_authorization def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"operation_id={self.operation_id}" - ) if self.operation_id is not None else None - out.append( - f"revoke_id={self.revoke_id}" - ) if self.revoke_id is not None else None - out.append( - f"contract_id={self.contract_id}" - ) if self.contract_id is not None else None - out.append( - f"soroban_authorization={self.soroban_authorization}" - ) if self.soroban_authorization is not None else None + out.append(f'type={self.type}') + out.append(f'operation_id={self.operation_id}') if self.operation_id is not None else None + out.append(f'revoke_id={self.revoke_id}') if self.revoke_id is not None else None + out.append(f'contract_id={self.contract_id}') if self.contract_id is not None else None + out.append(f'soroban_authorization={self.soroban_authorization}') if self.soroban_authorization is not None else None return f"" diff --git a/stellar_sdk/xdr/hash_id_preimage_contract_id.py b/stellar_sdk/xdr/hash_id_preimage_contract_id.py index 45c4203a..f903aefc 100644 --- a/stellar_sdk/xdr/hash_id_preimage_contract_id.py +++ b/stellar_sdk/xdr/hash_id_preimage_contract_id.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .contract_id_preimage import ContractIDPreimage from .hash import Hash - -__all__ = ["HashIDPreimageContractID"] - - +from .contract_id_preimage import ContractIDPreimage +__all__ = ['HashIDPreimageContractID'] class HashIDPreimageContractID: """ XDR Source Code:: @@ -22,7 +22,6 @@ class HashIDPreimageContractID: ContractIDPreimage contractIDPreimage; } """ - def __init__( self, network_id: Hash, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.network_id = network_id self.contract_id_preimage = contract_id_preimage - def pack(self, packer: Packer) -> None: self.network_id.pack(packer) self.contract_id_preimage.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> HashIDPreimageContractID: network_id = Hash.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> HashIDPreimageContractID: network_id=network_id, contract_id_preimage=contract_id_preimage, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> HashIDPreimageContractID: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.network_id, - self.contract_id_preimage, - ) - ) - + return hash((self.network_id, self.contract_id_preimage,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.network_id == other.network_id - and self.contract_id_preimage == other.contract_id_preimage - ) - + return self.network_id== other.network_id and self.contract_id_preimage== other.contract_id_preimage def __str__(self): out = [ - f"network_id={self.network_id}", - f"contract_id_preimage={self.contract_id_preimage}", + f'network_id={self.network_id}', + f'contract_id_preimage={self.contract_id_preimage}', ] return f"" diff --git a/stellar_sdk/xdr/hash_id_preimage_operation_id.py b/stellar_sdk/xdr/hash_id_preimage_operation_id.py index 19c4301e..442ea0bb 100644 --- a/stellar_sdk/xdr/hash_id_preimage_operation_id.py +++ b/stellar_sdk/xdr/hash_id_preimage_operation_id.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .sequence_number import SequenceNumber from .uint32 import Uint32 - -__all__ = ["HashIDPreimageOperationID"] - - +__all__ = ['HashIDPreimageOperationID'] class HashIDPreimageOperationID: """ XDR Source Code:: @@ -24,7 +24,6 @@ class HashIDPreimageOperationID: uint32 opNum; } """ - def __init__( self, source_account: AccountID, @@ -34,12 +33,10 @@ def __init__( self.source_account = source_account self.seq_num = seq_num self.op_num = op_num - def pack(self, packer: Packer) -> None: self.source_account.pack(packer) self.seq_num.pack(packer) self.op_num.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> HashIDPreimageOperationID: source_account = AccountID.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> HashIDPreimageOperationID: seq_num=seq_num, op_num=op_num, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> HashIDPreimageOperationID: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.source_account, - self.seq_num, - self.op_num, - ) - ) - + return hash((self.source_account, self.seq_num, self.op_num,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.source_account == other.source_account - and self.seq_num == other.seq_num - and self.op_num == other.op_num - ) - + return self.source_account== other.source_account and self.seq_num== other.seq_num and self.op_num== other.op_num def __str__(self): out = [ - f"source_account={self.source_account}", - f"seq_num={self.seq_num}", - f"op_num={self.op_num}", + f'source_account={self.source_account}', + f'seq_num={self.seq_num}', + f'op_num={self.op_num}', ] return f"" diff --git a/stellar_sdk/xdr/hash_id_preimage_revoke_id.py b/stellar_sdk/xdr/hash_id_preimage_revoke_id.py index e265db0e..d5538704 100644 --- a/stellar_sdk/xdr/hash_id_preimage_revoke_id.py +++ b/stellar_sdk/xdr/hash_id_preimage_revoke_id.py @@ -3,18 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID -from .asset import Asset -from .pool_id import PoolID from .sequence_number import SequenceNumber from .uint32 import Uint32 - -__all__ = ["HashIDPreimageRevokeID"] - - +from .pool_id import PoolID +from .asset import Asset +__all__ = ['HashIDPreimageRevokeID'] class HashIDPreimageRevokeID: """ XDR Source Code:: @@ -22,13 +22,12 @@ class HashIDPreimageRevokeID: struct { AccountID sourceAccount; - SequenceNumber seqNum; + SequenceNumber seqNum; uint32 opNum; PoolID liquidityPoolID; Asset asset; } """ - def __init__( self, source_account: AccountID, @@ -42,14 +41,12 @@ def __init__( self.op_num = op_num self.liquidity_pool_id = liquidity_pool_id self.asset = asset - def pack(self, packer: Packer) -> None: self.source_account.pack(packer) self.seq_num.pack(packer) self.op_num.pack(packer) self.liquidity_pool_id.pack(packer) self.asset.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> HashIDPreimageRevokeID: source_account = AccountID.unpack(unpacker) @@ -64,7 +61,6 @@ def unpack(cls, unpacker: Unpacker) -> HashIDPreimageRevokeID: liquidity_pool_id=liquidity_pool_id, asset=asset, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -83,35 +79,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> HashIDPreimageRevokeID: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.source_account, - self.seq_num, - self.op_num, - self.liquidity_pool_id, - self.asset, - ) - ) - + return hash((self.source_account, self.seq_num, self.op_num, self.liquidity_pool_id, self.asset,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.source_account == other.source_account - and self.seq_num == other.seq_num - and self.op_num == other.op_num - and self.liquidity_pool_id == other.liquidity_pool_id - and self.asset == other.asset - ) - + return self.source_account== other.source_account and self.seq_num== other.seq_num and self.op_num== other.op_num and self.liquidity_pool_id== other.liquidity_pool_id and self.asset== other.asset def __str__(self): out = [ - f"source_account={self.source_account}", - f"seq_num={self.seq_num}", - f"op_num={self.op_num}", - f"liquidity_pool_id={self.liquidity_pool_id}", - f"asset={self.asset}", + f'source_account={self.source_account}', + f'seq_num={self.seq_num}', + f'op_num={self.op_num}', + f'liquidity_pool_id={self.liquidity_pool_id}', + f'asset={self.asset}', ] return f"" diff --git a/stellar_sdk/xdr/hash_id_preimage_soroban_authorization.py b/stellar_sdk/xdr/hash_id_preimage_soroban_authorization.py index 30587a84..59e75add 100644 --- a/stellar_sdk/xdr/hash_id_preimage_soroban_authorization.py +++ b/stellar_sdk/xdr/hash_id_preimage_soroban_authorization.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash from .int64 import Int64 -from .soroban_authorized_invocation import SorobanAuthorizedInvocation from .uint32 import Uint32 - -__all__ = ["HashIDPreimageSorobanAuthorization"] - - +from .soroban_authorized_invocation import SorobanAuthorizedInvocation +__all__ = ['HashIDPreimageSorobanAuthorization'] class HashIDPreimageSorobanAuthorization: """ XDR Source Code:: @@ -26,7 +26,6 @@ class HashIDPreimageSorobanAuthorization: SorobanAuthorizedInvocation invocation; } """ - def __init__( self, network_id: Hash, @@ -38,13 +37,11 @@ def __init__( self.nonce = nonce self.signature_expiration_ledger = signature_expiration_ledger self.invocation = invocation - def pack(self, packer: Packer) -> None: self.network_id.pack(packer) self.nonce.pack(packer) self.signature_expiration_ledger.pack(packer) self.invocation.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> HashIDPreimageSorobanAuthorization: network_id = Hash.unpack(unpacker) @@ -57,7 +54,6 @@ def unpack(cls, unpacker: Unpacker) -> HashIDPreimageSorobanAuthorization: signature_expiration_ledger=signature_expiration_ledger, invocation=invocation, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -76,32 +72,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> HashIDPreimageSorobanAuthorization: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.network_id, - self.nonce, - self.signature_expiration_ledger, - self.invocation, - ) - ) - + return hash((self.network_id, self.nonce, self.signature_expiration_ledger, self.invocation,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.network_id == other.network_id - and self.nonce == other.nonce - and self.signature_expiration_ledger == other.signature_expiration_ledger - and self.invocation == other.invocation - ) - + return self.network_id== other.network_id and self.nonce== other.nonce and self.signature_expiration_ledger== other.signature_expiration_ledger and self.invocation== other.invocation def __str__(self): out = [ - f"network_id={self.network_id}", - f"nonce={self.nonce}", - f"signature_expiration_ledger={self.signature_expiration_ledger}", - f"invocation={self.invocation}", + f'network_id={self.network_id}', + f'nonce={self.nonce}', + f'signature_expiration_ledger={self.signature_expiration_ledger}', + f'invocation={self.invocation}', ] return f"" diff --git a/stellar_sdk/xdr/hello.py b/stellar_sdk/xdr/hello.py index 8f771f6a..2ef6cb69 100644 --- a/stellar_sdk/xdr/hello.py +++ b/stellar_sdk/xdr/hello.py @@ -3,19 +3,20 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .auth_cert import AuthCert -from .base import Integer, String +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 from .hash import Hash from .node_id import NodeID -from .uint32 import Uint32 +from .auth_cert import AuthCert from .uint256 import Uint256 - -__all__ = ["Hello"] - - +__all__ = ['Hello'] class Hello: """ XDR Source Code:: @@ -33,7 +34,6 @@ class Hello: uint256 nonce; }; """ - def __init__( self, ledger_version: Uint32, @@ -55,7 +55,6 @@ def __init__( self.peer_id = peer_id self.cert = cert self.nonce = nonce - def pack(self, packer: Packer) -> None: self.ledger_version.pack(packer) self.overlay_version.pack(packer) @@ -66,7 +65,6 @@ def pack(self, packer: Packer) -> None: self.peer_id.pack(packer) self.cert.pack(packer) self.nonce.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Hello: ledger_version = Uint32.unpack(unpacker) @@ -89,7 +87,6 @@ def unpack(cls, unpacker: Unpacker) -> Hello: cert=cert, nonce=nonce, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -108,47 +105,22 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Hello: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_version, - self.overlay_version, - self.overlay_min_version, - self.network_id, - self.version_str, - self.listening_port, - self.peer_id, - self.cert, - self.nonce, - ) - ) - + return hash((self.ledger_version, self.overlay_version, self.overlay_min_version, self.network_id, self.version_str, self.listening_port, self.peer_id, self.cert, self.nonce,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_version == other.ledger_version - and self.overlay_version == other.overlay_version - and self.overlay_min_version == other.overlay_min_version - and self.network_id == other.network_id - and self.version_str == other.version_str - and self.listening_port == other.listening_port - and self.peer_id == other.peer_id - and self.cert == other.cert - and self.nonce == other.nonce - ) - + return self.ledger_version== other.ledger_version and self.overlay_version== other.overlay_version and self.overlay_min_version== other.overlay_min_version and self.network_id== other.network_id and self.version_str== other.version_str and self.listening_port== other.listening_port and self.peer_id== other.peer_id and self.cert== other.cert and self.nonce== other.nonce def __str__(self): out = [ - f"ledger_version={self.ledger_version}", - f"overlay_version={self.overlay_version}", - f"overlay_min_version={self.overlay_min_version}", - f"network_id={self.network_id}", - f"version_str={self.version_str}", - f"listening_port={self.listening_port}", - f"peer_id={self.peer_id}", - f"cert={self.cert}", - f"nonce={self.nonce}", + f'ledger_version={self.ledger_version}', + f'overlay_version={self.overlay_version}', + f'overlay_min_version={self.overlay_min_version}', + f'network_id={self.network_id}', + f'version_str={self.version_str}', + f'listening_port={self.listening_port}', + f'peer_id={self.peer_id}', + f'cert={self.cert}', + f'nonce={self.nonce}', ] return f"" diff --git a/stellar_sdk/xdr/hmac_sha256_key.py b/stellar_sdk/xdr/hmac_sha256_key.py index 9e39459a..0ff7d554 100644 --- a/stellar_sdk/xdr/hmac_sha256_key.py +++ b/stellar_sdk/xdr/hmac_sha256_key.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["HmacSha256Key"] - - +__all__ = ['HmacSha256Key'] class HmacSha256Key: """ XDR Source Code:: @@ -20,23 +19,19 @@ class HmacSha256Key: opaque key[32]; }; """ - def __init__( self, key: bytes, ) -> None: self.key = key - def pack(self, packer: Packer) -> None: Opaque(self.key, 32, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> HmacSha256Key: key = Opaque.unpack(unpacker, 32, True) return cls( key=key, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +50,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> HmacSha256Key: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.key,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.key == other.key - + return self.key== other.key def __str__(self): out = [ - f"key={self.key}", + f'key={self.key}', ] return f"" diff --git a/stellar_sdk/xdr/hmac_sha256_mac.py b/stellar_sdk/xdr/hmac_sha256_mac.py index 548868c1..dc66b877 100644 --- a/stellar_sdk/xdr/hmac_sha256_mac.py +++ b/stellar_sdk/xdr/hmac_sha256_mac.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["HmacSha256Mac"] - - +__all__ = ['HmacSha256Mac'] class HmacSha256Mac: """ XDR Source Code:: @@ -20,23 +19,19 @@ class HmacSha256Mac: opaque mac[32]; }; """ - def __init__( self, mac: bytes, ) -> None: self.mac = mac - def pack(self, packer: Packer) -> None: Opaque(self.mac, 32, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> HmacSha256Mac: mac = Opaque.unpack(unpacker, 32, True) return cls( mac=mac, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +50,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> HmacSha256Mac: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.mac,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.mac == other.mac - + return self.mac== other.mac def __str__(self): out = [ - f"mac={self.mac}", + f'mac={self.mac}', ] return f"" diff --git a/stellar_sdk/xdr/host_function.py b/stellar_sdk/xdr/host_function.py index c4436bea..bc9c04ed 100644 --- a/stellar_sdk/xdr/host_function.py +++ b/stellar_sdk/xdr/host_function.py @@ -3,17 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque -from .create_contract_args import CreateContractArgs from .host_function_type import HostFunctionType from .invoke_contract_args import InvokeContractArgs - -__all__ = ["HostFunction"] - - +from .create_contract_args import CreateContractArgs +__all__ = ['HostFunction'] class HostFunction: """ XDR Source Code:: @@ -28,7 +27,6 @@ class HostFunction: opaque wasm<>; }; """ - def __init__( self, type: HostFunctionType, @@ -40,7 +38,6 @@ def __init__( self.invoke_contract = invoke_contract self.create_contract = create_contract self.wasm = wasm - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == HostFunctionType.HOST_FUNCTION_TYPE_INVOKE_CONTRACT: @@ -58,7 +55,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("wasm should not be None.") Opaque(self.wasm, 4294967295, False).pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> HostFunction: type = HostFunctionType.unpack(unpacker) @@ -72,7 +68,6 @@ def unpack(cls, unpacker: Unpacker) -> HostFunction: wasm = Opaque.unpack(unpacker, 4294967295, False) return cls(type=type, wasm=wasm) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -91,35 +86,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> HostFunction: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.invoke_contract, - self.create_contract, - self.wasm, - ) - ) - + return hash((self.type, self.invoke_contract, self.create_contract, self.wasm,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.invoke_contract == other.invoke_contract - and self.create_contract == other.create_contract - and self.wasm == other.wasm - ) - + return self.type== other.type and self.invoke_contract== other.invoke_contract and self.create_contract== other.create_contract and self.wasm== other.wasm def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"invoke_contract={self.invoke_contract}" - ) if self.invoke_contract is not None else None - out.append( - f"create_contract={self.create_contract}" - ) if self.create_contract is not None else None - out.append(f"wasm={self.wasm}") if self.wasm is not None else None + out.append(f'type={self.type}') + out.append(f'invoke_contract={self.invoke_contract}') if self.invoke_contract is not None else None + out.append(f'create_contract={self.create_contract}') if self.create_contract is not None else None + out.append(f'wasm={self.wasm}') if self.wasm is not None else None return f"" diff --git a/stellar_sdk/xdr/host_function_type.py b/stellar_sdk/xdr/host_function_type.py index ca84bf9a..0ac71213 100644 --- a/stellar_sdk/xdr/host_function_type.py +++ b/stellar_sdk/xdr/host_function_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["HostFunctionType"] - - +__all__ = ['HostFunctionType'] class HostFunctionType(IntEnum): """ XDR Source Code:: @@ -21,11 +21,9 @@ class HostFunctionType(IntEnum): HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2 }; """ - HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0 HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1 HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -33,7 +31,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> HostFunctionType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/inflation_payout.py b/stellar_sdk/xdr/inflation_payout.py index 0d9dcf4a..e3466b3e 100644 --- a/stellar_sdk/xdr/inflation_payout.py +++ b/stellar_sdk/xdr/inflation_payout.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .int64 import Int64 - -__all__ = ["InflationPayout"] - - +__all__ = ['InflationPayout'] class InflationPayout: """ XDR Source Code:: @@ -22,7 +22,6 @@ class InflationPayout: int64 amount; }; """ - def __init__( self, destination: AccountID, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.destination = destination self.amount = amount - def pack(self, packer: Packer) -> None: self.destination.pack(packer) self.amount.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> InflationPayout: destination = AccountID.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> InflationPayout: destination=destination, amount=amount, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InflationPayout: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.destination, - self.amount, - ) - ) - + return hash((self.destination, self.amount,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.destination == other.destination and self.amount == other.amount - + return self.destination== other.destination and self.amount== other.amount def __str__(self): out = [ - f"destination={self.destination}", - f"amount={self.amount}", + f'destination={self.destination}', + f'amount={self.amount}', ] return f"" diff --git a/stellar_sdk/xdr/inflation_result.py b/stellar_sdk/xdr/inflation_result.py index 99930507..df418d32 100644 --- a/stellar_sdk/xdr/inflation_result.py +++ b/stellar_sdk/xdr/inflation_result.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .inflation_payout import InflationPayout from .inflation_result_code import InflationResultCode - -__all__ = ["InflationResult"] - - +from .inflation_payout import InflationPayout +__all__ = ['InflationResult'] class InflationResult: """ XDR Source Code:: @@ -25,7 +24,6 @@ class InflationResult: void; }; """ - def __init__( self, code: InflationResultCode, @@ -33,12 +31,9 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if payouts and len(payouts) > _expect_max_length: - raise ValueError( - f"The maximum length of `payouts` should be {_expect_max_length}, but got {len(payouts)}." - ) + raise ValueError(f"The maximum length of `payouts` should be {_expect_max_length}, but got {len(payouts)}.") self.code = code self.payouts = payouts - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == InflationResultCode.INFLATION_SUCCESS: @@ -50,7 +45,6 @@ def pack(self, packer: Packer) -> None: return if self.code == InflationResultCode.INFLATION_NOT_TIME: return - @classmethod def unpack(cls, unpacker: Unpacker) -> InflationResult: code = InflationResultCode.unpack(unpacker) @@ -63,7 +57,6 @@ def unpack(cls, unpacker: Unpacker) -> InflationResult: if code == InflationResultCode.INFLATION_NOT_TIME: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -82,22 +75,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InflationResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.payouts, - ) - ) - + return hash((self.code, self.payouts,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code and self.payouts == other.payouts - + return self.code== other.code and self.payouts== other.payouts def __str__(self): out = [] - out.append(f"code={self.code}") - out.append(f"payouts={self.payouts}") if self.payouts is not None else None + out.append(f'code={self.code}') + out.append(f'payouts={self.payouts}') if self.payouts is not None else None return f"" diff --git a/stellar_sdk/xdr/inflation_result_code.py b/stellar_sdk/xdr/inflation_result_code.py index c81c0bdf..019f8b5c 100644 --- a/stellar_sdk/xdr/inflation_result_code.py +++ b/stellar_sdk/xdr/inflation_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["InflationResultCode"] - - +__all__ = ['InflationResultCode'] class InflationResultCode(IntEnum): """ XDR Source Code:: @@ -22,10 +22,8 @@ class InflationResultCode(IntEnum): INFLATION_NOT_TIME = -1 }; """ - INFLATION_SUCCESS = 0 INFLATION_NOT_TIME = -1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -33,7 +31,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> InflationResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/inner_transaction_result.py b/stellar_sdk/xdr/inner_transaction_result.py index ac6e4fc5..7269ba65 100644 --- a/stellar_sdk/xdr/inner_transaction_result.py +++ b/stellar_sdk/xdr/inner_transaction_result.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .inner_transaction_result_ext import InnerTransactionResultExt -from .inner_transaction_result_result import InnerTransactionResultResult from .int64 import Int64 - -__all__ = ["InnerTransactionResult"] - - +from .inner_transaction_result_result import InnerTransactionResultResult +from .inner_transaction_result_ext import InnerTransactionResultExt +__all__ = ['InnerTransactionResult'] class InnerTransactionResult: """ XDR Source Code:: @@ -57,7 +57,6 @@ class InnerTransactionResult: ext; }; """ - def __init__( self, fee_charged: Int64, @@ -67,12 +66,10 @@ def __init__( self.fee_charged = fee_charged self.result = result self.ext = ext - def pack(self, packer: Packer) -> None: self.fee_charged.pack(packer) self.result.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> InnerTransactionResult: fee_charged = Int64.unpack(unpacker) @@ -83,7 +80,6 @@ def unpack(cls, unpacker: Unpacker) -> InnerTransactionResult: result=result, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,29 +98,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InnerTransactionResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.fee_charged, - self.result, - self.ext, - ) - ) - + return hash((self.fee_charged, self.result, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.fee_charged == other.fee_charged - and self.result == other.result - and self.ext == other.ext - ) - + return self.fee_charged== other.fee_charged and self.result== other.result and self.ext== other.ext def __str__(self): out = [ - f"fee_charged={self.fee_charged}", - f"result={self.result}", - f"ext={self.ext}", + f'fee_charged={self.fee_charged}', + f'result={self.result}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/inner_transaction_result_ext.py b/stellar_sdk/xdr/inner_transaction_result_ext.py index 810134ac..288dfe93 100644 --- a/stellar_sdk/xdr/inner_transaction_result_ext.py +++ b/stellar_sdk/xdr/inner_transaction_result_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["InnerTransactionResultExt"] - - +__all__ = ['InnerTransactionResultExt'] class InnerTransactionResultExt: """ XDR Source Code:: @@ -21,25 +20,21 @@ class InnerTransactionResultExt: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> InnerTransactionResultExt: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InnerTransactionResultExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/inner_transaction_result_pair.py b/stellar_sdk/xdr/inner_transaction_result_pair.py index b36c05ba..99ff46ea 100644 --- a/stellar_sdk/xdr/inner_transaction_result_pair.py +++ b/stellar_sdk/xdr/inner_transaction_result_pair.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash from .inner_transaction_result import InnerTransactionResult - -__all__ = ["InnerTransactionResultPair"] - - +__all__ = ['InnerTransactionResultPair'] class InnerTransactionResultPair: """ XDR Source Code:: @@ -22,7 +22,6 @@ class InnerTransactionResultPair: InnerTransactionResult result; // result for the inner transaction }; """ - def __init__( self, transaction_hash: Hash, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.transaction_hash = transaction_hash self.result = result - def pack(self, packer: Packer) -> None: self.transaction_hash.pack(packer) self.result.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> InnerTransactionResultPair: transaction_hash = Hash.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> InnerTransactionResultPair: transaction_hash=transaction_hash, result=result, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InnerTransactionResultPair: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.transaction_hash, - self.result, - ) - ) - + return hash((self.transaction_hash, self.result,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.transaction_hash == other.transaction_hash - and self.result == other.result - ) - + return self.transaction_hash== other.transaction_hash and self.result== other.result def __str__(self): out = [ - f"transaction_hash={self.transaction_hash}", - f"result={self.result}", + f'transaction_hash={self.transaction_hash}', + f'result={self.result}', ] return f"" diff --git a/stellar_sdk/xdr/inner_transaction_result_result.py b/stellar_sdk/xdr/inner_transaction_result_result.py index 1f065ca0..f213dfd8 100644 --- a/stellar_sdk/xdr/inner_transaction_result_result.py +++ b/stellar_sdk/xdr/inner_transaction_result_result.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .operation_result import OperationResult from .transaction_result_code import TransactionResultCode - -__all__ = ["InnerTransactionResultResult"] - - +from .operation_result import OperationResult +__all__ = ['InnerTransactionResultResult'] class InnerTransactionResultResult: """ XDR Source Code:: @@ -42,7 +41,6 @@ class InnerTransactionResultResult: void; } """ - def __init__( self, code: TransactionResultCode, @@ -50,12 +48,9 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if results and len(results) > _expect_max_length: - raise ValueError( - f"The maximum length of `results` should be {_expect_max_length}, but got {len(results)}." - ) + raise ValueError(f"The maximum length of `results` should be {_expect_max_length}, but got {len(results)}.") self.code = code self.results = results - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == TransactionResultCode.txSUCCESS: @@ -102,7 +97,6 @@ def pack(self, packer: Packer) -> None: return if self.code == TransactionResultCode.txSOROBAN_INVALID: return - @classmethod def unpack(cls, unpacker: Unpacker) -> InnerTransactionResultResult: code = TransactionResultCode.unpack(unpacker) @@ -149,7 +143,6 @@ def unpack(cls, unpacker: Unpacker) -> InnerTransactionResultResult: if code == TransactionResultCode.txSOROBAN_INVALID: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -168,22 +161,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InnerTransactionResultResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.results, - ) - ) - + return hash((self.code, self.results,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code and self.results == other.results - + return self.code== other.code and self.results== other.results def __str__(self): out = [] - out.append(f"code={self.code}") - out.append(f"results={self.results}") if self.results is not None else None + out.append(f'code={self.code}') + out.append(f'results={self.results}') if self.results is not None else None return f"" diff --git a/stellar_sdk/xdr/int128_parts.py b/stellar_sdk/xdr/int128_parts.py index e63eaef0..7f96905b 100644 --- a/stellar_sdk/xdr/int128_parts.py +++ b/stellar_sdk/xdr/int128_parts.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int64 import Int64 from .uint64 import Uint64 - -__all__ = ["Int128Parts"] - - +__all__ = ['Int128Parts'] class Int128Parts: """ XDR Source Code:: @@ -21,7 +21,6 @@ class Int128Parts: uint64 lo; }; """ - def __init__( self, hi: Int64, @@ -29,11 +28,9 @@ def __init__( ) -> None: self.hi = hi self.lo = lo - def pack(self, packer: Packer) -> None: self.hi.pack(packer) self.lo.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Int128Parts: hi = Int64.unpack(unpacker) @@ -42,7 +39,6 @@ def unpack(cls, unpacker: Unpacker) -> Int128Parts: hi=hi, lo=lo, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,23 +57,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Int128Parts: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.hi, - self.lo, - ) - ) - + return hash((self.hi, self.lo,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.hi == other.hi and self.lo == other.lo - + return self.hi== other.hi and self.lo== other.lo def __str__(self): out = [ - f"hi={self.hi}", - f"lo={self.lo}", + f'hi={self.hi}', + f'lo={self.lo}', ] return f"" diff --git a/stellar_sdk/xdr/int256_parts.py b/stellar_sdk/xdr/int256_parts.py index 4500ec35..91634a09 100644 --- a/stellar_sdk/xdr/int256_parts.py +++ b/stellar_sdk/xdr/int256_parts.py @@ -3,15 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int64 import Int64 from .uint64 import Uint64 - -__all__ = ["Int256Parts"] - - +from .uint64 import Uint64 +from .uint64 import Uint64 +__all__ = ['Int256Parts'] class Int256Parts: """ XDR Source Code:: @@ -23,7 +25,6 @@ class Int256Parts: uint64 lo_lo; }; """ - def __init__( self, hi_hi: Int64, @@ -35,13 +36,11 @@ def __init__( self.hi_lo = hi_lo self.lo_hi = lo_hi self.lo_lo = lo_lo - def pack(self, packer: Packer) -> None: self.hi_hi.pack(packer) self.hi_lo.pack(packer) self.lo_hi.pack(packer) self.lo_lo.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Int256Parts: hi_hi = Int64.unpack(unpacker) @@ -54,7 +53,6 @@ def unpack(cls, unpacker: Unpacker) -> Int256Parts: lo_hi=lo_hi, lo_lo=lo_lo, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,32 +71,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Int256Parts: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.hi_hi, - self.hi_lo, - self.lo_hi, - self.lo_lo, - ) - ) - + return hash((self.hi_hi, self.hi_lo, self.lo_hi, self.lo_lo,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.hi_hi == other.hi_hi - and self.hi_lo == other.hi_lo - and self.lo_hi == other.lo_hi - and self.lo_lo == other.lo_lo - ) - + return self.hi_hi== other.hi_hi and self.hi_lo== other.hi_lo and self.lo_hi== other.lo_hi and self.lo_lo== other.lo_lo def __str__(self): out = [ - f"hi_hi={self.hi_hi}", - f"hi_lo={self.hi_lo}", - f"lo_hi={self.lo_hi}", - f"lo_lo={self.lo_lo}", + f'hi_hi={self.hi_hi}', + f'hi_lo={self.hi_lo}', + f'lo_hi={self.lo_hi}', + f'lo_lo={self.lo_lo}', ] return f"" diff --git a/stellar_sdk/xdr/int32.py b/stellar_sdk/xdr/int32.py index b19d5dac..7019d5af 100644 --- a/stellar_sdk/xdr/int32.py +++ b/stellar_sdk/xdr/int32.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["Int32"] - - +__all__ = ['Int32'] class Int32: """ XDR Source Code:: typedef int int32; """ - def __init__(self, int32: int) -> None: self.int32 = int32 - def pack(self, packer: Packer) -> None: Integer(self.int32).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Int32: int32 = Integer.unpack(unpacker) return cls(int32) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Int32: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.int32) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/int64.py b/stellar_sdk/xdr/int64.py index 78352c57..263c23a8 100644 --- a/stellar_sdk/xdr/int64.py +++ b/stellar_sdk/xdr/int64.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Hyper - -__all__ = ["Int64"] - - +__all__ = ['Int64'] class Int64: """ XDR Source Code:: typedef hyper int64; """ - def __init__(self, int64: int) -> None: self.int64 = int64 - def pack(self, packer: Packer) -> None: Hyper(self.int64).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Int64: int64 = Hyper.unpack(unpacker) return cls(int64) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Int64: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.int64) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/invoke_contract_args.py b/stellar_sdk/xdr/invoke_contract_args.py new file mode 100644 index 00000000..bb5cb7e3 --- /dev/null +++ b/stellar_sdk/xdr/invoke_contract_args.py @@ -0,0 +1,87 @@ +# This is an automatically generated file. +# DO NOT EDIT or your changes may be overwritten +from __future__ import annotations + +import base64 +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING +from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * + +from .sc_address import SCAddress +from .sc_symbol import SCSymbol +from .sc_val import SCVal +__all__ = ['InvokeContractArgs'] +class InvokeContractArgs: + """ + XDR Source Code:: + + struct InvokeContractArgs { + SCAddress contractAddress; + SCSymbol functionName; + SCVal args<>; + }; + """ + def __init__( + self, + contract_address: SCAddress, + function_name: SCSymbol, + args: List[SCVal], + ) -> None: + _expect_max_length = 4294967295 + if args and len(args) > _expect_max_length: + raise ValueError(f"The maximum length of `args` should be {_expect_max_length}, but got {len(args)}.") + self.contract_address = contract_address + self.function_name = function_name + self.args = args + def pack(self, packer: Packer) -> None: + self.contract_address.pack(packer) + self.function_name.pack(packer) + packer.pack_uint(len(self.args)) + for args_item in self.args: + args_item.pack(packer) + @classmethod + def unpack(cls, unpacker: Unpacker) -> InvokeContractArgs: + contract_address = SCAddress.unpack(unpacker) + function_name = SCSymbol.unpack(unpacker) + length = unpacker.unpack_uint() + args = [] + for _ in range(length): + args.append(SCVal.unpack(unpacker)) + return cls( + contract_address=contract_address, + function_name=function_name, + args=args, + ) + def to_xdr_bytes(self) -> bytes: + packer = Packer() + self.pack(packer) + return packer.get_buffer() + + @classmethod + def from_xdr_bytes(cls, xdr: bytes) -> InvokeContractArgs: + unpacker = Unpacker(xdr) + return cls.unpack(unpacker) + + def to_xdr(self) -> str: + xdr_bytes = self.to_xdr_bytes() + return base64.b64encode(xdr_bytes).decode() + + @classmethod + def from_xdr(cls, xdr: str) -> InvokeContractArgs: + xdr_bytes = base64.b64decode(xdr.encode()) + return cls.from_xdr_bytes(xdr_bytes) + def __hash__(self): + return hash((self.contract_address, self.function_name, self.args,)) + def __eq__(self, other: object): + if not isinstance(other, self.__class__): + return NotImplemented + return self.contract_address== other.contract_address and self.function_name== other.function_name and self.args== other.args + def __str__(self): + out = [ + f'contract_address={self.contract_address}', + f'function_name={self.function_name}', + f'args={self.args}', + ] + return f"" diff --git a/stellar_sdk/xdr/invoke_host_function_op.py b/stellar_sdk/xdr/invoke_host_function_op.py index 7bf8165a..cd3daddc 100644 --- a/stellar_sdk/xdr/invoke_host_function_op.py +++ b/stellar_sdk/xdr/invoke_host_function_op.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .host_function import HostFunction from .soroban_authorization_entry import SorobanAuthorizationEntry - -__all__ = ["InvokeHostFunctionOp"] - - +__all__ = ['InvokeHostFunctionOp'] class InvokeHostFunctionOp: """ XDR Source Code:: @@ -25,7 +24,6 @@ class InvokeHostFunctionOp: SorobanAuthorizationEntry auth<>; }; """ - def __init__( self, host_function: HostFunction, @@ -33,18 +31,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if auth and len(auth) > _expect_max_length: - raise ValueError( - f"The maximum length of `auth` should be {_expect_max_length}, but got {len(auth)}." - ) + raise ValueError(f"The maximum length of `auth` should be {_expect_max_length}, but got {len(auth)}.") self.host_function = host_function self.auth = auth - def pack(self, packer: Packer) -> None: self.host_function.pack(packer) packer.pack_uint(len(self.auth)) for auth_item in self.auth: auth_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> InvokeHostFunctionOp: host_function = HostFunction.unpack(unpacker) @@ -56,7 +50,6 @@ def unpack(cls, unpacker: Unpacker) -> InvokeHostFunctionOp: host_function=host_function, auth=auth, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -75,23 +68,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InvokeHostFunctionOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.host_function, - self.auth, - ) - ) - + return hash((self.host_function, self.auth,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.host_function == other.host_function and self.auth == other.auth - + return self.host_function== other.host_function and self.auth== other.auth def __str__(self): out = [ - f"host_function={self.host_function}", - f"auth={self.auth}", + f'host_function={self.host_function}', + f'auth={self.auth}', ] return f"" diff --git a/stellar_sdk/xdr/invoke_host_function_result.py b/stellar_sdk/xdr/invoke_host_function_result.py index 5449d9e7..9f66835f 100644 --- a/stellar_sdk/xdr/invoke_host_function_result.py +++ b/stellar_sdk/xdr/invoke_host_function_result.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .hash import Hash from .invoke_host_function_result_code import InvokeHostFunctionResultCode - -__all__ = ["InvokeHostFunctionResult"] - - +from .hash import Hash +__all__ = ['InvokeHostFunctionResult'] class InvokeHostFunctionResult: """ XDR Source Code:: @@ -28,7 +28,6 @@ class InvokeHostFunctionResult: void; }; """ - def __init__( self, code: InvokeHostFunctionResultCode, @@ -36,7 +35,6 @@ def __init__( ) -> None: self.code = code self.success = success - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_SUCCESS: @@ -48,19 +46,12 @@ def pack(self, packer: Packer) -> None: return if self.code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_TRAPPED: return - if ( - self.code - == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED - ): + if self.code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: return if self.code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: return - if ( - self.code - == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE - ): + if self.code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: return - @classmethod def unpack(cls, unpacker: Unpacker) -> InvokeHostFunctionResult: code = InvokeHostFunctionResultCode.unpack(unpacker) @@ -71,20 +62,13 @@ def unpack(cls, unpacker: Unpacker) -> InvokeHostFunctionResult: return cls(code=code) if code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_TRAPPED: return cls(code=code) - if ( - code - == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED - ): + if code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: return cls(code=code) if code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: return cls(code=code) - if ( - code - == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE - ): + if code == InvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -103,22 +87,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InvokeHostFunctionResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.success, - ) - ) - + return hash((self.code, self.success,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code and self.success == other.success - + return self.code== other.code and self.success== other.success def __str__(self): out = [] - out.append(f"code={self.code}") - out.append(f"success={self.success}") if self.success is not None else None + out.append(f'code={self.code}') + out.append(f'success={self.success}') if self.success is not None else None return f"" diff --git a/stellar_sdk/xdr/invoke_host_function_result_code.py b/stellar_sdk/xdr/invoke_host_function_result_code.py index 0989d21c..376ffea0 100644 --- a/stellar_sdk/xdr/invoke_host_function_result_code.py +++ b/stellar_sdk/xdr/invoke_host_function_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["InvokeHostFunctionResultCode"] - - +__all__ = ['InvokeHostFunctionResultCode'] class InvokeHostFunctionResultCode(IntEnum): """ XDR Source Code:: @@ -27,14 +27,12 @@ class InvokeHostFunctionResultCode(IntEnum): INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE = -5 }; """ - INVOKE_HOST_FUNCTION_SUCCESS = 0 INVOKE_HOST_FUNCTION_MALFORMED = -1 INVOKE_HOST_FUNCTION_TRAPPED = -2 INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED = -3 INVOKE_HOST_FUNCTION_ENTRY_EXPIRED = -4 INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE = -5 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -42,7 +40,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> InvokeHostFunctionResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/invoke_host_function_success_pre_image.py b/stellar_sdk/xdr/invoke_host_function_success_pre_image.py index db533ea4..09b07dc4 100644 --- a/stellar_sdk/xdr/invoke_host_function_success_pre_image.py +++ b/stellar_sdk/xdr/invoke_host_function_success_pre_image.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .contract_event import ContractEvent from .sc_val import SCVal - -__all__ = ["InvokeHostFunctionSuccessPreImage"] - - +from .contract_event import ContractEvent +__all__ = ['InvokeHostFunctionSuccessPreImage'] class InvokeHostFunctionSuccessPreImage: """ XDR Source Code:: @@ -23,7 +22,6 @@ class InvokeHostFunctionSuccessPreImage: ContractEvent events<>; }; """ - def __init__( self, return_value: SCVal, @@ -31,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if events and len(events) > _expect_max_length: - raise ValueError( - f"The maximum length of `events` should be {_expect_max_length}, but got {len(events)}." - ) + raise ValueError(f"The maximum length of `events` should be {_expect_max_length}, but got {len(events)}.") self.return_value = return_value self.events = events - def pack(self, packer: Packer) -> None: self.return_value.pack(packer) packer.pack_uint(len(self.events)) for events_item in self.events: events_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> InvokeHostFunctionSuccessPreImage: return_value = SCVal.unpack(unpacker) @@ -54,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> InvokeHostFunctionSuccessPreImage: return_value=return_value, events=events, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,23 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> InvokeHostFunctionSuccessPreImage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.return_value, - self.events, - ) - ) - + return hash((self.return_value, self.events,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.return_value == other.return_value and self.events == other.events - + return self.return_value== other.return_value and self.events== other.events def __str__(self): out = [ - f"return_value={self.return_value}", - f"events={self.events}", + f'return_value={self.return_value}', + f'events={self.events}', ] return f"" diff --git a/stellar_sdk/xdr/ip_addr_type.py b/stellar_sdk/xdr/ip_addr_type.py index 04da85ea..4e0f8dfc 100644 --- a/stellar_sdk/xdr/ip_addr_type.py +++ b/stellar_sdk/xdr/ip_addr_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["IPAddrType"] - - +__all__ = ['IPAddrType'] class IPAddrType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class IPAddrType(IntEnum): IPv6 = 1 }; """ - IPv4 = 0 IPv6 = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> IPAddrType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/ledger_bounds.py b/stellar_sdk/xdr/ledger_bounds.py index 81fe0e11..034092b7 100644 --- a/stellar_sdk/xdr/ledger_bounds.py +++ b/stellar_sdk/xdr/ledger_bounds.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint32 import Uint32 - -__all__ = ["LedgerBounds"] - - +from .uint32 import Uint32 +__all__ = ['LedgerBounds'] class LedgerBounds: """ XDR Source Code:: @@ -21,7 +22,6 @@ class LedgerBounds: uint32 maxLedger; // 0 here means no maxLedger }; """ - def __init__( self, min_ledger: Uint32, @@ -29,11 +29,9 @@ def __init__( ) -> None: self.min_ledger = min_ledger self.max_ledger = max_ledger - def pack(self, packer: Packer) -> None: self.min_ledger.pack(packer) self.max_ledger.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerBounds: min_ledger = Uint32.unpack(unpacker) @@ -42,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerBounds: min_ledger=min_ledger, max_ledger=max_ledger, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,25 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerBounds: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.min_ledger, - self.max_ledger, - ) - ) - + return hash((self.min_ledger, self.max_ledger,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.min_ledger == other.min_ledger and self.max_ledger == other.max_ledger - ) - + return self.min_ledger== other.min_ledger and self.max_ledger== other.max_ledger def __str__(self): out = [ - f"min_ledger={self.min_ledger}", - f"max_ledger={self.max_ledger}", + f'min_ledger={self.min_ledger}', + f'max_ledger={self.max_ledger}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_close_meta.py b/stellar_sdk/xdr/ledger_close_meta.py index 6424cee9..1d396f40 100644 --- a/stellar_sdk/xdr/ledger_close_meta.py +++ b/stellar_sdk/xdr/ledger_close_meta.py @@ -3,17 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .ledger_close_meta_v0 import LedgerCloseMetaV0 from .ledger_close_meta_v1 import LedgerCloseMetaV1 from .ledger_close_meta_v2 import LedgerCloseMetaV2 - -__all__ = ["LedgerCloseMeta"] - - +__all__ = ['LedgerCloseMeta'] class LedgerCloseMeta: """ XDR Source Code:: @@ -28,7 +27,6 @@ class LedgerCloseMeta: LedgerCloseMetaV2 v2; }; """ - def __init__( self, v: int, @@ -40,7 +38,6 @@ def __init__( self.v0 = v0 self.v1 = v1 self.v2 = v2 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -58,7 +55,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v2 should not be None.") self.v2.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerCloseMeta: v = Integer.unpack(unpacker) @@ -72,7 +68,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerCloseMeta: v2 = LedgerCloseMetaV2.unpack(unpacker) return cls(v=v, v2=v2) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -91,31 +86,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerCloseMeta: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v0, - self.v1, - self.v2, - ) - ) - + return hash((self.v, self.v0, self.v1, self.v2,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.v == other.v - and self.v0 == other.v0 - and self.v1 == other.v1 - and self.v2 == other.v2 - ) - + return self.v== other.v and self.v0== other.v0 and self.v1== other.v1 and self.v2== other.v2 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v0={self.v0}") if self.v0 is not None else None - out.append(f"v1={self.v1}") if self.v1 is not None else None - out.append(f"v2={self.v2}") if self.v2 is not None else None + out.append(f'v={self.v}') + out.append(f'v0={self.v0}') if self.v0 is not None else None + out.append(f'v1={self.v1}') if self.v1 is not None else None + out.append(f'v2={self.v2}') if self.v2 is not None else None return f"" diff --git a/stellar_sdk/xdr/ledger_close_meta_v0.py b/stellar_sdk/xdr/ledger_close_meta_v0.py index c199861a..7a243654 100644 --- a/stellar_sdk/xdr/ledger_close_meta_v0.py +++ b/stellar_sdk/xdr/ledger_close_meta_v0.py @@ -3,19 +3,18 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .ledger_header_history_entry import LedgerHeaderHistoryEntry -from .scp_history_entry import SCPHistoryEntry -from .transaction_result_meta import TransactionResultMeta from .transaction_set import TransactionSet +from .transaction_result_meta import TransactionResultMeta from .upgrade_entry_meta import UpgradeEntryMeta - -__all__ = ["LedgerCloseMetaV0"] - - +from .scp_history_entry import SCPHistoryEntry +__all__ = ['LedgerCloseMetaV0'] class LedgerCloseMetaV0: """ XDR Source Code:: @@ -38,7 +37,6 @@ class LedgerCloseMetaV0: SCPHistoryEntry scpInfo<>; }; """ - def __init__( self, ledger_header: LedgerHeaderHistoryEntry, @@ -49,25 +47,18 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if tx_processing and len(tx_processing) > _expect_max_length: - raise ValueError( - f"The maximum length of `tx_processing` should be {_expect_max_length}, but got {len(tx_processing)}." - ) + raise ValueError(f"The maximum length of `tx_processing` should be {_expect_max_length}, but got {len(tx_processing)}.") _expect_max_length = 4294967295 if upgrades_processing and len(upgrades_processing) > _expect_max_length: - raise ValueError( - f"The maximum length of `upgrades_processing` should be {_expect_max_length}, but got {len(upgrades_processing)}." - ) + raise ValueError(f"The maximum length of `upgrades_processing` should be {_expect_max_length}, but got {len(upgrades_processing)}.") _expect_max_length = 4294967295 if scp_info and len(scp_info) > _expect_max_length: - raise ValueError( - f"The maximum length of `scp_info` should be {_expect_max_length}, but got {len(scp_info)}." - ) + raise ValueError(f"The maximum length of `scp_info` should be {_expect_max_length}, but got {len(scp_info)}.") self.ledger_header = ledger_header self.tx_set = tx_set self.tx_processing = tx_processing self.upgrades_processing = upgrades_processing self.scp_info = scp_info - def pack(self, packer: Packer) -> None: self.ledger_header.pack(packer) self.tx_set.pack(packer) @@ -80,7 +71,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.scp_info)) for scp_info_item in self.scp_info: scp_info_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerCloseMetaV0: ledger_header = LedgerHeaderHistoryEntry.unpack(unpacker) @@ -104,7 +94,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerCloseMetaV0: upgrades_processing=upgrades_processing, scp_info=scp_info, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -123,35 +112,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerCloseMetaV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_header, - self.tx_set, - self.tx_processing, - self.upgrades_processing, - self.scp_info, - ) - ) - + return hash((self.ledger_header, self.tx_set, self.tx_processing, self.upgrades_processing, self.scp_info,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_header == other.ledger_header - and self.tx_set == other.tx_set - and self.tx_processing == other.tx_processing - and self.upgrades_processing == other.upgrades_processing - and self.scp_info == other.scp_info - ) - + return self.ledger_header== other.ledger_header and self.tx_set== other.tx_set and self.tx_processing== other.tx_processing and self.upgrades_processing== other.upgrades_processing and self.scp_info== other.scp_info def __str__(self): out = [ - f"ledger_header={self.ledger_header}", - f"tx_set={self.tx_set}", - f"tx_processing={self.tx_processing}", - f"upgrades_processing={self.upgrades_processing}", - f"scp_info={self.scp_info}", + f'ledger_header={self.ledger_header}', + f'tx_set={self.tx_set}', + f'tx_processing={self.tx_processing}', + f'upgrades_processing={self.upgrades_processing}', + f'scp_info={self.scp_info}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_close_meta_v1.py b/stellar_sdk/xdr/ledger_close_meta_v1.py index 91fc79b9..14a688ef 100644 --- a/stellar_sdk/xdr/ledger_close_meta_v1.py +++ b/stellar_sdk/xdr/ledger_close_meta_v1.py @@ -3,19 +3,18 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .generalized_transaction_set import GeneralizedTransactionSet from .ledger_header_history_entry import LedgerHeaderHistoryEntry -from .scp_history_entry import SCPHistoryEntry +from .generalized_transaction_set import GeneralizedTransactionSet from .transaction_result_meta import TransactionResultMeta from .upgrade_entry_meta import UpgradeEntryMeta - -__all__ = ["LedgerCloseMetaV1"] - - +from .scp_history_entry import SCPHistoryEntry +__all__ = ['LedgerCloseMetaV1'] class LedgerCloseMetaV1: """ XDR Source Code:: @@ -38,7 +37,6 @@ class LedgerCloseMetaV1: SCPHistoryEntry scpInfo<>; }; """ - def __init__( self, ledger_header: LedgerHeaderHistoryEntry, @@ -49,25 +47,18 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if tx_processing and len(tx_processing) > _expect_max_length: - raise ValueError( - f"The maximum length of `tx_processing` should be {_expect_max_length}, but got {len(tx_processing)}." - ) + raise ValueError(f"The maximum length of `tx_processing` should be {_expect_max_length}, but got {len(tx_processing)}.") _expect_max_length = 4294967295 if upgrades_processing and len(upgrades_processing) > _expect_max_length: - raise ValueError( - f"The maximum length of `upgrades_processing` should be {_expect_max_length}, but got {len(upgrades_processing)}." - ) + raise ValueError(f"The maximum length of `upgrades_processing` should be {_expect_max_length}, but got {len(upgrades_processing)}.") _expect_max_length = 4294967295 if scp_info and len(scp_info) > _expect_max_length: - raise ValueError( - f"The maximum length of `scp_info` should be {_expect_max_length}, but got {len(scp_info)}." - ) + raise ValueError(f"The maximum length of `scp_info` should be {_expect_max_length}, but got {len(scp_info)}.") self.ledger_header = ledger_header self.tx_set = tx_set self.tx_processing = tx_processing self.upgrades_processing = upgrades_processing self.scp_info = scp_info - def pack(self, packer: Packer) -> None: self.ledger_header.pack(packer) self.tx_set.pack(packer) @@ -80,7 +71,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.scp_info)) for scp_info_item in self.scp_info: scp_info_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerCloseMetaV1: ledger_header = LedgerHeaderHistoryEntry.unpack(unpacker) @@ -104,7 +94,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerCloseMetaV1: upgrades_processing=upgrades_processing, scp_info=scp_info, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -123,35 +112,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerCloseMetaV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_header, - self.tx_set, - self.tx_processing, - self.upgrades_processing, - self.scp_info, - ) - ) - + return hash((self.ledger_header, self.tx_set, self.tx_processing, self.upgrades_processing, self.scp_info,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_header == other.ledger_header - and self.tx_set == other.tx_set - and self.tx_processing == other.tx_processing - and self.upgrades_processing == other.upgrades_processing - and self.scp_info == other.scp_info - ) - + return self.ledger_header== other.ledger_header and self.tx_set== other.tx_set and self.tx_processing== other.tx_processing and self.upgrades_processing== other.upgrades_processing and self.scp_info== other.scp_info def __str__(self): out = [ - f"ledger_header={self.ledger_header}", - f"tx_set={self.tx_set}", - f"tx_processing={self.tx_processing}", - f"upgrades_processing={self.upgrades_processing}", - f"scp_info={self.scp_info}", + f'ledger_header={self.ledger_header}', + f'tx_set={self.tx_set}', + f'tx_processing={self.tx_processing}', + f'upgrades_processing={self.upgrades_processing}', + f'scp_info={self.scp_info}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_close_meta_v2.py b/stellar_sdk/xdr/ledger_close_meta_v2.py index 8eafb67c..c926a279 100644 --- a/stellar_sdk/xdr/ledger_close_meta_v2.py +++ b/stellar_sdk/xdr/ledger_close_meta_v2.py @@ -3,23 +3,22 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .extension_point import ExtensionPoint -from .generalized_transaction_set import GeneralizedTransactionSet -from .ledger_entry import LedgerEntry from .ledger_header_history_entry import LedgerHeaderHistoryEntry -from .ledger_key import LedgerKey -from .scp_history_entry import SCPHistoryEntry +from .generalized_transaction_set import GeneralizedTransactionSet from .transaction_result_meta import TransactionResultMeta -from .uint64 import Uint64 from .upgrade_entry_meta import UpgradeEntryMeta - -__all__ = ["LedgerCloseMetaV2"] - - +from .scp_history_entry import SCPHistoryEntry +from .uint64 import Uint64 +from .ledger_key import LedgerKey +from .ledger_entry import LedgerEntry +__all__ = ['LedgerCloseMetaV2'] class LedgerCloseMetaV2: """ XDR Source Code:: @@ -57,7 +56,6 @@ class LedgerCloseMetaV2: LedgerEntry evictedPersistentLedgerEntries<>; }; """ - def __init__( self, ext: ExtensionPoint, @@ -72,35 +70,19 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if tx_processing and len(tx_processing) > _expect_max_length: - raise ValueError( - f"The maximum length of `tx_processing` should be {_expect_max_length}, but got {len(tx_processing)}." - ) + raise ValueError(f"The maximum length of `tx_processing` should be {_expect_max_length}, but got {len(tx_processing)}.") _expect_max_length = 4294967295 if upgrades_processing and len(upgrades_processing) > _expect_max_length: - raise ValueError( - f"The maximum length of `upgrades_processing` should be {_expect_max_length}, but got {len(upgrades_processing)}." - ) + raise ValueError(f"The maximum length of `upgrades_processing` should be {_expect_max_length}, but got {len(upgrades_processing)}.") _expect_max_length = 4294967295 if scp_info and len(scp_info) > _expect_max_length: - raise ValueError( - f"The maximum length of `scp_info` should be {_expect_max_length}, but got {len(scp_info)}." - ) + raise ValueError(f"The maximum length of `scp_info` should be {_expect_max_length}, but got {len(scp_info)}.") _expect_max_length = 4294967295 - if ( - evicted_temporary_ledger_keys - and len(evicted_temporary_ledger_keys) > _expect_max_length - ): - raise ValueError( - f"The maximum length of `evicted_temporary_ledger_keys` should be {_expect_max_length}, but got {len(evicted_temporary_ledger_keys)}." - ) + if evicted_temporary_ledger_keys and len(evicted_temporary_ledger_keys) > _expect_max_length: + raise ValueError(f"The maximum length of `evicted_temporary_ledger_keys` should be {_expect_max_length}, but got {len(evicted_temporary_ledger_keys)}.") _expect_max_length = 4294967295 - if ( - evicted_persistent_ledger_entries - and len(evicted_persistent_ledger_entries) > _expect_max_length - ): - raise ValueError( - f"The maximum length of `evicted_persistent_ledger_entries` should be {_expect_max_length}, but got {len(evicted_persistent_ledger_entries)}." - ) + if evicted_persistent_ledger_entries and len(evicted_persistent_ledger_entries) > _expect_max_length: + raise ValueError(f"The maximum length of `evicted_persistent_ledger_entries` should be {_expect_max_length}, but got {len(evicted_persistent_ledger_entries)}.") self.ext = ext self.ledger_header = ledger_header self.tx_set = tx_set @@ -110,7 +92,6 @@ def __init__( self.total_byte_size_of_bucket_list = total_byte_size_of_bucket_list self.evicted_temporary_ledger_keys = evicted_temporary_ledger_keys self.evicted_persistent_ledger_entries = evicted_persistent_ledger_entries - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.ledger_header.pack(packer) @@ -129,11 +110,8 @@ def pack(self, packer: Packer) -> None: for evicted_temporary_ledger_keys_item in self.evicted_temporary_ledger_keys: evicted_temporary_ledger_keys_item.pack(packer) packer.pack_uint(len(self.evicted_persistent_ledger_entries)) - for ( - evicted_persistent_ledger_entries_item - ) in self.evicted_persistent_ledger_entries: + for evicted_persistent_ledger_entries_item in self.evicted_persistent_ledger_entries: evicted_persistent_ledger_entries_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerCloseMetaV2: ext = ExtensionPoint.unpack(unpacker) @@ -171,7 +149,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerCloseMetaV2: evicted_temporary_ledger_keys=evicted_temporary_ledger_keys, evicted_persistent_ledger_entries=evicted_persistent_ledger_entries, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -190,50 +167,22 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerCloseMetaV2: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.ledger_header, - self.tx_set, - self.tx_processing, - self.upgrades_processing, - self.scp_info, - self.total_byte_size_of_bucket_list, - self.evicted_temporary_ledger_keys, - self.evicted_persistent_ledger_entries, - ) - ) - + return hash((self.ext, self.ledger_header, self.tx_set, self.tx_processing, self.upgrades_processing, self.scp_info, self.total_byte_size_of_bucket_list, self.evicted_temporary_ledger_keys, self.evicted_persistent_ledger_entries,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.ledger_header == other.ledger_header - and self.tx_set == other.tx_set - and self.tx_processing == other.tx_processing - and self.upgrades_processing == other.upgrades_processing - and self.scp_info == other.scp_info - and self.total_byte_size_of_bucket_list - == other.total_byte_size_of_bucket_list - and self.evicted_temporary_ledger_keys - == other.evicted_temporary_ledger_keys - and self.evicted_persistent_ledger_entries - == other.evicted_persistent_ledger_entries - ) - + return self.ext== other.ext and self.ledger_header== other.ledger_header and self.tx_set== other.tx_set and self.tx_processing== other.tx_processing and self.upgrades_processing== other.upgrades_processing and self.scp_info== other.scp_info and self.total_byte_size_of_bucket_list== other.total_byte_size_of_bucket_list and self.evicted_temporary_ledger_keys== other.evicted_temporary_ledger_keys and self.evicted_persistent_ledger_entries== other.evicted_persistent_ledger_entries def __str__(self): out = [ - f"ext={self.ext}", - f"ledger_header={self.ledger_header}", - f"tx_set={self.tx_set}", - f"tx_processing={self.tx_processing}", - f"upgrades_processing={self.upgrades_processing}", - f"scp_info={self.scp_info}", - f"total_byte_size_of_bucket_list={self.total_byte_size_of_bucket_list}", - f"evicted_temporary_ledger_keys={self.evicted_temporary_ledger_keys}", - f"evicted_persistent_ledger_entries={self.evicted_persistent_ledger_entries}", + f'ext={self.ext}', + f'ledger_header={self.ledger_header}', + f'tx_set={self.tx_set}', + f'tx_processing={self.tx_processing}', + f'upgrades_processing={self.upgrades_processing}', + f'scp_info={self.scp_info}', + f'total_byte_size_of_bucket_list={self.total_byte_size_of_bucket_list}', + f'evicted_temporary_ledger_keys={self.evicted_temporary_ledger_keys}', + f'evicted_persistent_ledger_entries={self.evicted_persistent_ledger_entries}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_close_value_signature.py b/stellar_sdk/xdr/ledger_close_value_signature.py index 5de4c0b1..a96cc066 100644 --- a/stellar_sdk/xdr/ledger_close_value_signature.py +++ b/stellar_sdk/xdr/ledger_close_value_signature.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .node_id import NodeID from .signature import Signature - -__all__ = ["LedgerCloseValueSignature"] - - +__all__ = ['LedgerCloseValueSignature'] class LedgerCloseValueSignature: """ XDR Source Code:: @@ -22,7 +22,6 @@ class LedgerCloseValueSignature: Signature signature; // nodeID's signature }; """ - def __init__( self, node_id: NodeID, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.node_id = node_id self.signature = signature - def pack(self, packer: Packer) -> None: self.node_id.pack(packer) self.signature.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerCloseValueSignature: node_id = NodeID.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerCloseValueSignature: node_id=node_id, signature=signature, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerCloseValueSignature: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.node_id, - self.signature, - ) - ) - + return hash((self.node_id, self.signature,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.node_id == other.node_id and self.signature == other.signature - + return self.node_id== other.node_id and self.signature== other.signature def __str__(self): out = [ - f"node_id={self.node_id}", - f"signature={self.signature}", + f'node_id={self.node_id}', + f'signature={self.signature}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_entry.py b/stellar_sdk/xdr/ledger_entry.py index 22240fcc..bcac9339 100644 --- a/stellar_sdk/xdr/ledger_entry.py +++ b/stellar_sdk/xdr/ledger_entry.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .uint32 import Uint32 from .ledger_entry_data import LedgerEntryData from .ledger_entry_ext import LedgerEntryExt -from .uint32 import Uint32 - -__all__ = ["LedgerEntry"] - - +__all__ = ['LedgerEntry'] class LedgerEntry: """ XDR Source Code:: @@ -57,7 +57,6 @@ class LedgerEntry: ext; }; """ - def __init__( self, last_modified_ledger_seq: Uint32, @@ -67,12 +66,10 @@ def __init__( self.last_modified_ledger_seq = last_modified_ledger_seq self.data = data self.ext = ext - def pack(self, packer: Packer) -> None: self.last_modified_ledger_seq.pack(packer) self.data.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerEntry: last_modified_ledger_seq = Uint32.unpack(unpacker) @@ -83,7 +80,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerEntry: data=data, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,29 +98,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.last_modified_ledger_seq, - self.data, - self.ext, - ) - ) - + return hash((self.last_modified_ledger_seq, self.data, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.last_modified_ledger_seq == other.last_modified_ledger_seq - and self.data == other.data - and self.ext == other.ext - ) - + return self.last_modified_ledger_seq== other.last_modified_ledger_seq and self.data== other.data and self.ext== other.ext def __str__(self): out = [ - f"last_modified_ledger_seq={self.last_modified_ledger_seq}", - f"data={self.data}", - f"ext={self.ext}", + f'last_modified_ledger_seq={self.last_modified_ledger_seq}', + f'data={self.data}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_entry_change.py b/stellar_sdk/xdr/ledger_entry_change.py index 823287b4..ee6f0fea 100644 --- a/stellar_sdk/xdr/ledger_entry_change.py +++ b/stellar_sdk/xdr/ledger_entry_change.py @@ -3,16 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .ledger_entry import LedgerEntry from .ledger_entry_change_type import LedgerEntryChangeType +from .ledger_entry import LedgerEntry +from .ledger_entry import LedgerEntry from .ledger_key import LedgerKey - -__all__ = ["LedgerEntryChange"] - - +from .ledger_entry import LedgerEntry +__all__ = ['LedgerEntryChange'] class LedgerEntryChange: """ XDR Source Code:: @@ -29,7 +31,6 @@ class LedgerEntryChange: LedgerEntry state; }; """ - def __init__( self, type: LedgerEntryChangeType, @@ -43,7 +44,6 @@ def __init__( self.updated = updated self.removed = removed self.state = state - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == LedgerEntryChangeType.LEDGER_ENTRY_CREATED: @@ -66,7 +66,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("state should not be None.") self.state.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerEntryChange: type = LedgerEntryChangeType.unpack(unpacker) @@ -83,7 +82,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerEntryChange: state = LedgerEntry.unpack(unpacker) return cls(type=type, state=state) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,34 +100,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerEntryChange: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.created, - self.updated, - self.removed, - self.state, - ) - ) - + return hash((self.type, self.created, self.updated, self.removed, self.state,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.created == other.created - and self.updated == other.updated - and self.removed == other.removed - and self.state == other.state - ) - + return self.type== other.type and self.created== other.created and self.updated== other.updated and self.removed== other.removed and self.state== other.state def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"created={self.created}") if self.created is not None else None - out.append(f"updated={self.updated}") if self.updated is not None else None - out.append(f"removed={self.removed}") if self.removed is not None else None - out.append(f"state={self.state}") if self.state is not None else None + out.append(f'type={self.type}') + out.append(f'created={self.created}') if self.created is not None else None + out.append(f'updated={self.updated}') if self.updated is not None else None + out.append(f'removed={self.removed}') if self.removed is not None else None + out.append(f'state={self.state}') if self.state is not None else None return f"" diff --git a/stellar_sdk/xdr/ledger_entry_change_type.py b/stellar_sdk/xdr/ledger_entry_change_type.py index cae8980d..ecb38b2e 100644 --- a/stellar_sdk/xdr/ledger_entry_change_type.py +++ b/stellar_sdk/xdr/ledger_entry_change_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["LedgerEntryChangeType"] - - +__all__ = ['LedgerEntryChangeType'] class LedgerEntryChangeType(IntEnum): """ XDR Source Code:: @@ -22,12 +22,10 @@ class LedgerEntryChangeType(IntEnum): LEDGER_ENTRY_STATE = 3 // value of the entry }; """ - LEDGER_ENTRY_CREATED = 0 LEDGER_ENTRY_UPDATED = 1 LEDGER_ENTRY_REMOVED = 2 LEDGER_ENTRY_STATE = 3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -35,7 +33,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> LedgerEntryChangeType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/ledger_entry_changes.py b/stellar_sdk/xdr/ledger_entry_changes.py index 6b963009..775aafa6 100644 --- a/stellar_sdk/xdr/ledger_entry_changes.py +++ b/stellar_sdk/xdr/ledger_entry_changes.py @@ -3,35 +3,29 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .ledger_entry_change import LedgerEntryChange - -__all__ = ["LedgerEntryChanges"] - - +__all__ = ['LedgerEntryChanges'] class LedgerEntryChanges: """ XDR Source Code:: typedef LedgerEntryChange LedgerEntryChanges<>; """ - def __init__(self, ledger_entry_changes: List[LedgerEntryChange]) -> None: _expect_max_length = 4294967295 if ledger_entry_changes and len(ledger_entry_changes) > _expect_max_length: - raise ValueError( - f"The maximum length of `ledger_entry_changes` should be {_expect_max_length}, but got {len(ledger_entry_changes)}." - ) + raise ValueError(f"The maximum length of `ledger_entry_changes` should be {_expect_max_length}, but got {len(ledger_entry_changes)}.") self.ledger_entry_changes = ledger_entry_changes - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.ledger_entry_changes)) for ledger_entry_changes_item in self.ledger_entry_changes: ledger_entry_changes_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerEntryChanges: length = unpacker.unpack_uint() @@ -39,7 +33,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerEntryChanges: for _ in range(length): ledger_entry_changes.append(LedgerEntryChange.unpack(unpacker)) return cls(ledger_entry_changes) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +51,12 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerEntryChanges: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.ledger_entry_changes) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented return self.ledger_entry_changes == other.ledger_entry_changes def __str__(self): - return ( - f"" - ) + return f"" diff --git a/stellar_sdk/xdr/ledger_entry_data.py b/stellar_sdk/xdr/ledger_entry_data.py index 004e70c3..3e34c74f 100644 --- a/stellar_sdk/xdr/ledger_entry_data.py +++ b/stellar_sdk/xdr/ledger_entry_data.py @@ -3,24 +3,24 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .ledger_entry_type import LedgerEntryType from .account_entry import AccountEntry +from .trust_line_entry import TrustLineEntry +from .offer_entry import OfferEntry +from .data_entry import DataEntry from .claimable_balance_entry import ClaimableBalanceEntry -from .config_setting_entry import ConfigSettingEntry -from .contract_code_entry import ContractCodeEntry +from .liquidity_pool_entry import LiquidityPoolEntry from .contract_data_entry import ContractDataEntry -from .data_entry import DataEntry +from .contract_code_entry import ContractCodeEntry +from .config_setting_entry import ConfigSettingEntry from .expiration_entry import ExpirationEntry -from .ledger_entry_type import LedgerEntryType -from .liquidity_pool_entry import LiquidityPoolEntry -from .offer_entry import OfferEntry -from .trust_line_entry import TrustLineEntry - -__all__ = ["LedgerEntryData"] - - +__all__ = ['LedgerEntryData'] class LedgerEntryData: """ XDR Source Code:: @@ -49,7 +49,6 @@ class LedgerEntryData: ExpirationEntry expiration; } """ - def __init__( self, type: LedgerEntryType, @@ -75,7 +74,6 @@ def __init__( self.contract_code = contract_code self.config_setting = config_setting self.expiration = expiration - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == LedgerEntryType.ACCOUNT: @@ -128,7 +126,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("expiration should not be None.") self.expiration.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerEntryData: type = LedgerEntryType.unpack(unpacker) @@ -163,7 +160,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerEntryData: expiration = ExpirationEntry.unpack(unpacker) return cls(type=type, expiration=expiration) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -182,66 +178,23 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerEntryData: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.account, - self.trust_line, - self.offer, - self.data, - self.claimable_balance, - self.liquidity_pool, - self.contract_data, - self.contract_code, - self.config_setting, - self.expiration, - ) - ) - + return hash((self.type, self.account, self.trust_line, self.offer, self.data, self.claimable_balance, self.liquidity_pool, self.contract_data, self.contract_code, self.config_setting, self.expiration,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.account == other.account - and self.trust_line == other.trust_line - and self.offer == other.offer - and self.data == other.data - and self.claimable_balance == other.claimable_balance - and self.liquidity_pool == other.liquidity_pool - and self.contract_data == other.contract_data - and self.contract_code == other.contract_code - and self.config_setting == other.config_setting - and self.expiration == other.expiration - ) - + return self.type== other.type and self.account== other.account and self.trust_line== other.trust_line and self.offer== other.offer and self.data== other.data and self.claimable_balance== other.claimable_balance and self.liquidity_pool== other.liquidity_pool and self.contract_data== other.contract_data and self.contract_code== other.contract_code and self.config_setting== other.config_setting and self.expiration== other.expiration def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"account={self.account}") if self.account is not None else None - out.append( - f"trust_line={self.trust_line}" - ) if self.trust_line is not None else None - out.append(f"offer={self.offer}") if self.offer is not None else None - out.append(f"data={self.data}") if self.data is not None else None - out.append( - f"claimable_balance={self.claimable_balance}" - ) if self.claimable_balance is not None else None - out.append( - f"liquidity_pool={self.liquidity_pool}" - ) if self.liquidity_pool is not None else None - out.append( - f"contract_data={self.contract_data}" - ) if self.contract_data is not None else None - out.append( - f"contract_code={self.contract_code}" - ) if self.contract_code is not None else None - out.append( - f"config_setting={self.config_setting}" - ) if self.config_setting is not None else None - out.append( - f"expiration={self.expiration}" - ) if self.expiration is not None else None + out.append(f'type={self.type}') + out.append(f'account={self.account}') if self.account is not None else None + out.append(f'trust_line={self.trust_line}') if self.trust_line is not None else None + out.append(f'offer={self.offer}') if self.offer is not None else None + out.append(f'data={self.data}') if self.data is not None else None + out.append(f'claimable_balance={self.claimable_balance}') if self.claimable_balance is not None else None + out.append(f'liquidity_pool={self.liquidity_pool}') if self.liquidity_pool is not None else None + out.append(f'contract_data={self.contract_data}') if self.contract_data is not None else None + out.append(f'contract_code={self.contract_code}') if self.contract_code is not None else None + out.append(f'config_setting={self.config_setting}') if self.config_setting is not None else None + out.append(f'expiration={self.expiration}') if self.expiration is not None else None return f"" diff --git a/stellar_sdk/xdr/ledger_entry_ext.py b/stellar_sdk/xdr/ledger_entry_ext.py index 1cdf5eaf..0f1a5c35 100644 --- a/stellar_sdk/xdr/ledger_entry_ext.py +++ b/stellar_sdk/xdr/ledger_entry_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .ledger_entry_extension_v1 import LedgerEntryExtensionV1 - -__all__ = ["LedgerEntryExt"] - - +__all__ = ['LedgerEntryExt'] class LedgerEntryExt: """ XDR Source Code:: @@ -24,7 +23,6 @@ class LedgerEntryExt: LedgerEntryExtensionV1 v1; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.v1 = v1 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v1 should not be None.") self.v1.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerEntryExt: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerEntryExt: v1 = LedgerEntryExtensionV1.unpack(unpacker) return cls(v=v, v1=v1) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,22 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v1, - ) - ) - + return hash((self.v, self.v1,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v1 == other.v1 - + return self.v== other.v and self.v1== other.v1 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v1={self.v1}") if self.v1 is not None else None + out.append(f'v={self.v}') + out.append(f'v1={self.v1}') if self.v1 is not None else None return f"" diff --git a/stellar_sdk/xdr/ledger_entry_extension_v1.py b/stellar_sdk/xdr/ledger_entry_extension_v1.py index 60537421..56be9f4d 100644 --- a/stellar_sdk/xdr/ledger_entry_extension_v1.py +++ b/stellar_sdk/xdr/ledger_entry_extension_v1.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .ledger_entry_extension_v1_ext import LedgerEntryExtensionV1Ext from .sponsorship_descriptor import SponsorshipDescriptor - -__all__ = ["LedgerEntryExtensionV1"] - - +from .ledger_entry_extension_v1_ext import LedgerEntryExtensionV1Ext +__all__ = ['LedgerEntryExtensionV1'] class LedgerEntryExtensionV1: """ XDR Source Code:: @@ -28,7 +28,6 @@ class LedgerEntryExtensionV1: ext; }; """ - def __init__( self, sponsoring_id: SponsorshipDescriptor, @@ -36,11 +35,9 @@ def __init__( ) -> None: self.sponsoring_id = sponsoring_id self.ext = ext - def pack(self, packer: Packer) -> None: self.sponsoring_id.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerEntryExtensionV1: sponsoring_id = SponsorshipDescriptor.unpack(unpacker) @@ -49,7 +46,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerEntryExtensionV1: sponsoring_id=sponsoring_id, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -68,23 +64,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerEntryExtensionV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.sponsoring_id, - self.ext, - ) - ) - + return hash((self.sponsoring_id, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.sponsoring_id == other.sponsoring_id and self.ext == other.ext - + return self.sponsoring_id== other.sponsoring_id and self.ext== other.ext def __str__(self): out = [ - f"sponsoring_id={self.sponsoring_id}", - f"ext={self.ext}", + f'sponsoring_id={self.sponsoring_id}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_entry_extension_v1_ext.py b/stellar_sdk/xdr/ledger_entry_extension_v1_ext.py index d1d06760..e3036cf4 100644 --- a/stellar_sdk/xdr/ledger_entry_extension_v1_ext.py +++ b/stellar_sdk/xdr/ledger_entry_extension_v1_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["LedgerEntryExtensionV1Ext"] - - +__all__ = ['LedgerEntryExtensionV1Ext'] class LedgerEntryExtensionV1Ext: """ XDR Source Code:: @@ -21,25 +20,21 @@ class LedgerEntryExtensionV1Ext: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerEntryExtensionV1Ext: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerEntryExtensionV1Ext: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/ledger_entry_type.py b/stellar_sdk/xdr/ledger_entry_type.py index 19b1a0fd..a9aebd64 100644 --- a/stellar_sdk/xdr/ledger_entry_type.py +++ b/stellar_sdk/xdr/ledger_entry_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["LedgerEntryType"] - - +__all__ = ['LedgerEntryType'] class LedgerEntryType(IntEnum): """ XDR Source Code:: @@ -28,7 +28,6 @@ class LedgerEntryType(IntEnum): EXPIRATION = 9 }; """ - ACCOUNT = 0 TRUSTLINE = 1 OFFER = 2 @@ -39,7 +38,6 @@ class LedgerEntryType(IntEnum): CONTRACT_CODE = 7 CONFIG_SETTING = 8 EXPIRATION = 9 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -47,7 +45,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> LedgerEntryType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/ledger_footprint.py b/stellar_sdk/xdr/ledger_footprint.py index 67de4c5c..59b07f3c 100644 --- a/stellar_sdk/xdr/ledger_footprint.py +++ b/stellar_sdk/xdr/ledger_footprint.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .ledger_key import LedgerKey - -__all__ = ["LedgerFootprint"] - - +from .ledger_key import LedgerKey +__all__ = ['LedgerFootprint'] class LedgerFootprint: """ XDR Source Code:: @@ -22,7 +22,6 @@ class LedgerFootprint: LedgerKey readWrite<>; }; """ - def __init__( self, read_only: List[LedgerKey], @@ -30,17 +29,12 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if read_only and len(read_only) > _expect_max_length: - raise ValueError( - f"The maximum length of `read_only` should be {_expect_max_length}, but got {len(read_only)}." - ) + raise ValueError(f"The maximum length of `read_only` should be {_expect_max_length}, but got {len(read_only)}.") _expect_max_length = 4294967295 if read_write and len(read_write) > _expect_max_length: - raise ValueError( - f"The maximum length of `read_write` should be {_expect_max_length}, but got {len(read_write)}." - ) + raise ValueError(f"The maximum length of `read_write` should be {_expect_max_length}, but got {len(read_write)}.") self.read_only = read_only self.read_write = read_write - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.read_only)) for read_only_item in self.read_only: @@ -48,7 +42,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.read_write)) for read_write_item in self.read_write: read_write_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerFootprint: length = unpacker.unpack_uint() @@ -63,7 +56,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerFootprint: read_only=read_only, read_write=read_write, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -82,23 +74,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerFootprint: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.read_only, - self.read_write, - ) - ) - + return hash((self.read_only, self.read_write,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.read_only == other.read_only and self.read_write == other.read_write - + return self.read_only== other.read_only and self.read_write== other.read_write def __str__(self): out = [ - f"read_only={self.read_only}", - f"read_write={self.read_write}", + f'read_only={self.read_only}', + f'read_write={self.read_write}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_header.py b/stellar_sdk/xdr/ledger_header.py index 0c1384e2..d46bdc89 100644 --- a/stellar_sdk/xdr/ledger_header.py +++ b/stellar_sdk/xdr/ledger_header.py @@ -3,20 +3,28 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .uint32 import Uint32 from .hash import Hash -from .int64 import Int64 -from .ledger_header_ext import LedgerHeaderExt from .stellar_value import StellarValue +from .hash import Hash +from .hash import Hash +from .uint32 import Uint32 +from .int64 import Int64 +from .int64 import Int64 from .uint32 import Uint32 from .uint64 import Uint64 - -__all__ = ["LedgerHeader"] - - +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .hash import Hash +from .ledger_header_ext import LedgerHeaderExt +__all__ = ['LedgerHeader'] class LedgerHeader: """ XDR Source Code:: @@ -61,7 +69,6 @@ class LedgerHeader: ext; }; """ - def __init__( self, ledger_version: Uint32, @@ -82,9 +89,7 @@ def __init__( ) -> None: _expect_length = 4 if skip_list and len(skip_list) != _expect_length: - raise ValueError( - f"The length of `skip_list` should be {_expect_length}, but got {len(skip_list)}." - ) + raise ValueError(f"The length of `skip_list` should be {_expect_length}, but got {len(skip_list)}.") self.ledger_version = ledger_version self.previous_ledger_hash = previous_ledger_hash self.scp_value = scp_value @@ -100,7 +105,6 @@ def __init__( self.max_tx_set_size = max_tx_set_size self.skip_list = skip_list self.ext = ext - def pack(self, packer: Packer) -> None: self.ledger_version.pack(packer) self.previous_ledger_hash.pack(packer) @@ -118,7 +122,6 @@ def pack(self, packer: Packer) -> None: for skip_list_item in self.skip_list: skip_list_item.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerHeader: ledger_version = Uint32.unpack(unpacker) @@ -156,7 +159,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerHeader: skip_list=skip_list, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -175,65 +177,28 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerHeader: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_version, - self.previous_ledger_hash, - self.scp_value, - self.tx_set_result_hash, - self.bucket_list_hash, - self.ledger_seq, - self.total_coins, - self.fee_pool, - self.inflation_seq, - self.id_pool, - self.base_fee, - self.base_reserve, - self.max_tx_set_size, - self.skip_list, - self.ext, - ) - ) - + return hash((self.ledger_version, self.previous_ledger_hash, self.scp_value, self.tx_set_result_hash, self.bucket_list_hash, self.ledger_seq, self.total_coins, self.fee_pool, self.inflation_seq, self.id_pool, self.base_fee, self.base_reserve, self.max_tx_set_size, self.skip_list, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_version == other.ledger_version - and self.previous_ledger_hash == other.previous_ledger_hash - and self.scp_value == other.scp_value - and self.tx_set_result_hash == other.tx_set_result_hash - and self.bucket_list_hash == other.bucket_list_hash - and self.ledger_seq == other.ledger_seq - and self.total_coins == other.total_coins - and self.fee_pool == other.fee_pool - and self.inflation_seq == other.inflation_seq - and self.id_pool == other.id_pool - and self.base_fee == other.base_fee - and self.base_reserve == other.base_reserve - and self.max_tx_set_size == other.max_tx_set_size - and self.skip_list == other.skip_list - and self.ext == other.ext - ) - + return self.ledger_version== other.ledger_version and self.previous_ledger_hash== other.previous_ledger_hash and self.scp_value== other.scp_value and self.tx_set_result_hash== other.tx_set_result_hash and self.bucket_list_hash== other.bucket_list_hash and self.ledger_seq== other.ledger_seq and self.total_coins== other.total_coins and self.fee_pool== other.fee_pool and self.inflation_seq== other.inflation_seq and self.id_pool== other.id_pool and self.base_fee== other.base_fee and self.base_reserve== other.base_reserve and self.max_tx_set_size== other.max_tx_set_size and self.skip_list== other.skip_list and self.ext== other.ext def __str__(self): out = [ - f"ledger_version={self.ledger_version}", - f"previous_ledger_hash={self.previous_ledger_hash}", - f"scp_value={self.scp_value}", - f"tx_set_result_hash={self.tx_set_result_hash}", - f"bucket_list_hash={self.bucket_list_hash}", - f"ledger_seq={self.ledger_seq}", - f"total_coins={self.total_coins}", - f"fee_pool={self.fee_pool}", - f"inflation_seq={self.inflation_seq}", - f"id_pool={self.id_pool}", - f"base_fee={self.base_fee}", - f"base_reserve={self.base_reserve}", - f"max_tx_set_size={self.max_tx_set_size}", - f"skip_list={self.skip_list}", - f"ext={self.ext}", + f'ledger_version={self.ledger_version}', + f'previous_ledger_hash={self.previous_ledger_hash}', + f'scp_value={self.scp_value}', + f'tx_set_result_hash={self.tx_set_result_hash}', + f'bucket_list_hash={self.bucket_list_hash}', + f'ledger_seq={self.ledger_seq}', + f'total_coins={self.total_coins}', + f'fee_pool={self.fee_pool}', + f'inflation_seq={self.inflation_seq}', + f'id_pool={self.id_pool}', + f'base_fee={self.base_fee}', + f'base_reserve={self.base_reserve}', + f'max_tx_set_size={self.max_tx_set_size}', + f'skip_list={self.skip_list}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_header_ext.py b/stellar_sdk/xdr/ledger_header_ext.py index 9cb13e4e..e0b7d6ac 100644 --- a/stellar_sdk/xdr/ledger_header_ext.py +++ b/stellar_sdk/xdr/ledger_header_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .ledger_header_extension_v1 import LedgerHeaderExtensionV1 - -__all__ = ["LedgerHeaderExt"] - - +__all__ = ['LedgerHeaderExt'] class LedgerHeaderExt: """ XDR Source Code:: @@ -24,7 +23,6 @@ class LedgerHeaderExt: LedgerHeaderExtensionV1 v1; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.v1 = v1 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v1 should not be None.") self.v1.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerHeaderExt: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerHeaderExt: v1 = LedgerHeaderExtensionV1.unpack(unpacker) return cls(v=v, v1=v1) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,22 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerHeaderExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v1, - ) - ) - + return hash((self.v, self.v1,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v1 == other.v1 - + return self.v== other.v and self.v1== other.v1 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v1={self.v1}") if self.v1 is not None else None + out.append(f'v={self.v}') + out.append(f'v1={self.v1}') if self.v1 is not None else None return f"" diff --git a/stellar_sdk/xdr/ledger_header_extension_v1.py b/stellar_sdk/xdr/ledger_header_extension_v1.py index f2432013..81483966 100644 --- a/stellar_sdk/xdr/ledger_header_extension_v1.py +++ b/stellar_sdk/xdr/ledger_header_extension_v1.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .ledger_header_extension_v1_ext import LedgerHeaderExtensionV1Ext from .uint32 import Uint32 - -__all__ = ["LedgerHeaderExtensionV1"] - - +from .ledger_header_extension_v1_ext import LedgerHeaderExtensionV1Ext +__all__ = ['LedgerHeaderExtensionV1'] class LedgerHeaderExtensionV1: """ XDR Source Code:: @@ -28,7 +28,6 @@ class LedgerHeaderExtensionV1: ext; }; """ - def __init__( self, flags: Uint32, @@ -36,11 +35,9 @@ def __init__( ) -> None: self.flags = flags self.ext = ext - def pack(self, packer: Packer) -> None: self.flags.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerHeaderExtensionV1: flags = Uint32.unpack(unpacker) @@ -49,7 +46,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerHeaderExtensionV1: flags=flags, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -68,23 +64,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerHeaderExtensionV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.flags, - self.ext, - ) - ) - + return hash((self.flags, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.flags == other.flags and self.ext == other.ext - + return self.flags== other.flags and self.ext== other.ext def __str__(self): out = [ - f"flags={self.flags}", - f"ext={self.ext}", + f'flags={self.flags}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_header_extension_v1_ext.py b/stellar_sdk/xdr/ledger_header_extension_v1_ext.py index af7b4d02..dae265a2 100644 --- a/stellar_sdk/xdr/ledger_header_extension_v1_ext.py +++ b/stellar_sdk/xdr/ledger_header_extension_v1_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["LedgerHeaderExtensionV1Ext"] - - +__all__ = ['LedgerHeaderExtensionV1Ext'] class LedgerHeaderExtensionV1Ext: """ XDR Source Code:: @@ -21,25 +20,21 @@ class LedgerHeaderExtensionV1Ext: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerHeaderExtensionV1Ext: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerHeaderExtensionV1Ext: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/ledger_header_flags.py b/stellar_sdk/xdr/ledger_header_flags.py index 22e69a3b..fef649b4 100644 --- a/stellar_sdk/xdr/ledger_header_flags.py +++ b/stellar_sdk/xdr/ledger_header_flags.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["LedgerHeaderFlags"] - - +__all__ = ['LedgerHeaderFlags'] class LedgerHeaderFlags(IntEnum): """ XDR Source Code:: @@ -21,11 +21,9 @@ class LedgerHeaderFlags(IntEnum): DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG = 0x4 }; """ - DISABLE_LIQUIDITY_POOL_TRADING_FLAG = 1 DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG = 2 DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG = 4 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -33,7 +31,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> LedgerHeaderFlags: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/ledger_header_history_entry.py b/stellar_sdk/xdr/ledger_header_history_entry.py index de3b6008..83438a91 100644 --- a/stellar_sdk/xdr/ledger_header_history_entry.py +++ b/stellar_sdk/xdr/ledger_header_history_entry.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash from .ledger_header import LedgerHeader from .ledger_header_history_entry_ext import LedgerHeaderHistoryEntryExt - -__all__ = ["LedgerHeaderHistoryEntry"] - - +__all__ = ['LedgerHeaderHistoryEntry'] class LedgerHeaderHistoryEntry: """ XDR Source Code:: @@ -31,7 +31,6 @@ class LedgerHeaderHistoryEntry: ext; }; """ - def __init__( self, hash: Hash, @@ -41,12 +40,10 @@ def __init__( self.hash = hash self.header = header self.ext = ext - def pack(self, packer: Packer) -> None: self.hash.pack(packer) self.header.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerHeaderHistoryEntry: hash = Hash.unpack(unpacker) @@ -57,7 +54,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerHeaderHistoryEntry: header=header, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -76,29 +72,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerHeaderHistoryEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.hash, - self.header, - self.ext, - ) - ) - + return hash((self.hash, self.header, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.hash == other.hash - and self.header == other.header - and self.ext == other.ext - ) - + return self.hash== other.hash and self.header== other.header and self.ext== other.ext def __str__(self): out = [ - f"hash={self.hash}", - f"header={self.header}", - f"ext={self.ext}", + f'hash={self.hash}', + f'header={self.header}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_header_history_entry_ext.py b/stellar_sdk/xdr/ledger_header_history_entry_ext.py index e73d62e4..ad4ad35b 100644 --- a/stellar_sdk/xdr/ledger_header_history_entry_ext.py +++ b/stellar_sdk/xdr/ledger_header_history_entry_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["LedgerHeaderHistoryEntryExt"] - - +__all__ = ['LedgerHeaderHistoryEntryExt'] class LedgerHeaderHistoryEntryExt: """ XDR Source Code:: @@ -21,25 +20,21 @@ class LedgerHeaderHistoryEntryExt: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerHeaderHistoryEntryExt: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerHeaderHistoryEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/ledger_key.py b/stellar_sdk/xdr/ledger_key.py index be975004..1c04725b 100644 --- a/stellar_sdk/xdr/ledger_key.py +++ b/stellar_sdk/xdr/ledger_key.py @@ -3,24 +3,24 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .ledger_entry_type import LedgerEntryType from .ledger_key_account import LedgerKeyAccount +from .ledger_key_trust_line import LedgerKeyTrustLine +from .ledger_key_offer import LedgerKeyOffer +from .ledger_key_data import LedgerKeyData from .ledger_key_claimable_balance import LedgerKeyClaimableBalance -from .ledger_key_config_setting import LedgerKeyConfigSetting -from .ledger_key_contract_code import LedgerKeyContractCode +from .ledger_key_liquidity_pool import LedgerKeyLiquidityPool from .ledger_key_contract_data import LedgerKeyContractData -from .ledger_key_data import LedgerKeyData +from .ledger_key_contract_code import LedgerKeyContractCode +from .ledger_key_config_setting import LedgerKeyConfigSetting from .ledger_key_expiration import LedgerKeyExpiration -from .ledger_key_liquidity_pool import LedgerKeyLiquidityPool -from .ledger_key_offer import LedgerKeyOffer -from .ledger_key_trust_line import LedgerKeyTrustLine - -__all__ = ["LedgerKey"] - - +__all__ = ['LedgerKey'] class LedgerKey: """ XDR Source Code:: @@ -90,7 +90,6 @@ class LedgerKey: } expiration; }; """ - def __init__( self, type: LedgerEntryType, @@ -116,7 +115,6 @@ def __init__( self.contract_code = contract_code self.config_setting = config_setting self.expiration = expiration - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == LedgerEntryType.ACCOUNT: @@ -169,7 +167,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("expiration should not be None.") self.expiration.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKey: type = LedgerEntryType.unpack(unpacker) @@ -204,7 +201,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerKey: expiration = LedgerKeyExpiration.unpack(unpacker) return cls(type=type, expiration=expiration) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -223,66 +219,23 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKey: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.account, - self.trust_line, - self.offer, - self.data, - self.claimable_balance, - self.liquidity_pool, - self.contract_data, - self.contract_code, - self.config_setting, - self.expiration, - ) - ) - + return hash((self.type, self.account, self.trust_line, self.offer, self.data, self.claimable_balance, self.liquidity_pool, self.contract_data, self.contract_code, self.config_setting, self.expiration,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.account == other.account - and self.trust_line == other.trust_line - and self.offer == other.offer - and self.data == other.data - and self.claimable_balance == other.claimable_balance - and self.liquidity_pool == other.liquidity_pool - and self.contract_data == other.contract_data - and self.contract_code == other.contract_code - and self.config_setting == other.config_setting - and self.expiration == other.expiration - ) - + return self.type== other.type and self.account== other.account and self.trust_line== other.trust_line and self.offer== other.offer and self.data== other.data and self.claimable_balance== other.claimable_balance and self.liquidity_pool== other.liquidity_pool and self.contract_data== other.contract_data and self.contract_code== other.contract_code and self.config_setting== other.config_setting and self.expiration== other.expiration def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"account={self.account}") if self.account is not None else None - out.append( - f"trust_line={self.trust_line}" - ) if self.trust_line is not None else None - out.append(f"offer={self.offer}") if self.offer is not None else None - out.append(f"data={self.data}") if self.data is not None else None - out.append( - f"claimable_balance={self.claimable_balance}" - ) if self.claimable_balance is not None else None - out.append( - f"liquidity_pool={self.liquidity_pool}" - ) if self.liquidity_pool is not None else None - out.append( - f"contract_data={self.contract_data}" - ) if self.contract_data is not None else None - out.append( - f"contract_code={self.contract_code}" - ) if self.contract_code is not None else None - out.append( - f"config_setting={self.config_setting}" - ) if self.config_setting is not None else None - out.append( - f"expiration={self.expiration}" - ) if self.expiration is not None else None + out.append(f'type={self.type}') + out.append(f'account={self.account}') if self.account is not None else None + out.append(f'trust_line={self.trust_line}') if self.trust_line is not None else None + out.append(f'offer={self.offer}') if self.offer is not None else None + out.append(f'data={self.data}') if self.data is not None else None + out.append(f'claimable_balance={self.claimable_balance}') if self.claimable_balance is not None else None + out.append(f'liquidity_pool={self.liquidity_pool}') if self.liquidity_pool is not None else None + out.append(f'contract_data={self.contract_data}') if self.contract_data is not None else None + out.append(f'contract_code={self.contract_code}') if self.contract_code is not None else None + out.append(f'config_setting={self.config_setting}') if self.config_setting is not None else None + out.append(f'expiration={self.expiration}') if self.expiration is not None else None return f"" diff --git a/stellar_sdk/xdr/ledger_key_account.py b/stellar_sdk/xdr/ledger_key_account.py index f45fdda6..2d886f22 100644 --- a/stellar_sdk/xdr/ledger_key_account.py +++ b/stellar_sdk/xdr/ledger_key_account.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID - -__all__ = ["LedgerKeyAccount"] - - +__all__ = ['LedgerKeyAccount'] class LedgerKeyAccount: """ XDR Source Code:: @@ -20,23 +20,19 @@ class LedgerKeyAccount: AccountID accountID; } """ - def __init__( self, account_id: AccountID, ) -> None: self.account_id = account_id - def pack(self, packer: Packer) -> None: self.account_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyAccount: account_id = AccountID.unpack(unpacker) return cls( account_id=account_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyAccount: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.account_id,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.account_id == other.account_id - + return self.account_id== other.account_id def __str__(self): out = [ - f"account_id={self.account_id}", + f'account_id={self.account_id}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_key_claimable_balance.py b/stellar_sdk/xdr/ledger_key_claimable_balance.py index 8eb9c835..2d74e531 100644 --- a/stellar_sdk/xdr/ledger_key_claimable_balance.py +++ b/stellar_sdk/xdr/ledger_key_claimable_balance.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claimable_balance_id import ClaimableBalanceID - -__all__ = ["LedgerKeyClaimableBalance"] - - +__all__ = ['LedgerKeyClaimableBalance'] class LedgerKeyClaimableBalance: """ XDR Source Code:: @@ -20,23 +20,19 @@ class LedgerKeyClaimableBalance: ClaimableBalanceID balanceID; } """ - def __init__( self, balance_id: ClaimableBalanceID, ) -> None: self.balance_id = balance_id - def pack(self, packer: Packer) -> None: self.balance_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyClaimableBalance: balance_id = ClaimableBalanceID.unpack(unpacker) return cls( balance_id=balance_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyClaimableBalance: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.balance_id,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.balance_id == other.balance_id - + return self.balance_id== other.balance_id def __str__(self): out = [ - f"balance_id={self.balance_id}", + f'balance_id={self.balance_id}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_key_config_setting.py b/stellar_sdk/xdr/ledger_key_config_setting.py index ee0f6181..5f19cfa7 100644 --- a/stellar_sdk/xdr/ledger_key_config_setting.py +++ b/stellar_sdk/xdr/ledger_key_config_setting.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .config_setting_id import ConfigSettingID - -__all__ = ["LedgerKeyConfigSetting"] - - +__all__ = ['LedgerKeyConfigSetting'] class LedgerKeyConfigSetting: """ XDR Source Code:: @@ -20,23 +20,19 @@ class LedgerKeyConfigSetting: ConfigSettingID configSettingID; } """ - def __init__( self, config_setting_id: ConfigSettingID, ) -> None: self.config_setting_id = config_setting_id - def pack(self, packer: Packer) -> None: self.config_setting_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyConfigSetting: config_setting_id = ConfigSettingID.unpack(unpacker) return cls( config_setting_id=config_setting_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyConfigSetting: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.config_setting_id,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.config_setting_id == other.config_setting_id - + return self.config_setting_id== other.config_setting_id def __str__(self): out = [ - f"config_setting_id={self.config_setting_id}", + f'config_setting_id={self.config_setting_id}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_key_contract_code.py b/stellar_sdk/xdr/ledger_key_contract_code.py index 71f0a1b7..a1e459b5 100644 --- a/stellar_sdk/xdr/ledger_key_contract_code.py +++ b/stellar_sdk/xdr/ledger_key_contract_code.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash - -__all__ = ["LedgerKeyContractCode"] - - +__all__ = ['LedgerKeyContractCode'] class LedgerKeyContractCode: """ XDR Source Code:: @@ -20,23 +20,19 @@ class LedgerKeyContractCode: Hash hash; } """ - def __init__( self, hash: Hash, ) -> None: self.hash = hash - def pack(self, packer: Packer) -> None: self.hash.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyContractCode: hash = Hash.unpack(unpacker) return cls( hash=hash, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyContractCode: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.hash,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.hash == other.hash - + return self.hash== other.hash def __str__(self): out = [ - f"hash={self.hash}", + f'hash={self.hash}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_key_contract_data.py b/stellar_sdk/xdr/ledger_key_contract_data.py index 7f3c25ba..4e088c57 100644 --- a/stellar_sdk/xdr/ledger_key_contract_data.py +++ b/stellar_sdk/xdr/ledger_key_contract_data.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .contract_data_durability import ContractDataDurability from .sc_address import SCAddress from .sc_val import SCVal - -__all__ = ["LedgerKeyContractData"] - - +from .contract_data_durability import ContractDataDurability +__all__ = ['LedgerKeyContractData'] class LedgerKeyContractData: """ XDR Source Code:: @@ -24,7 +24,6 @@ class LedgerKeyContractData: ContractDataDurability durability; } """ - def __init__( self, contract: SCAddress, @@ -34,12 +33,10 @@ def __init__( self.contract = contract self.key = key self.durability = durability - def pack(self, packer: Packer) -> None: self.contract.pack(packer) self.key.pack(packer) self.durability.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyContractData: contract = SCAddress.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerKeyContractData: key=key, durability=durability, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyContractData: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.contract, - self.key, - self.durability, - ) - ) - + return hash((self.contract, self.key, self.durability,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.contract == other.contract - and self.key == other.key - and self.durability == other.durability - ) - + return self.contract== other.contract and self.key== other.key and self.durability== other.durability def __str__(self): out = [ - f"contract={self.contract}", - f"key={self.key}", - f"durability={self.durability}", + f'contract={self.contract}', + f'key={self.key}', + f'durability={self.durability}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_key_data.py b/stellar_sdk/xdr/ledger_key_data.py index 8e311b42..44e46ce3 100644 --- a/stellar_sdk/xdr/ledger_key_data.py +++ b/stellar_sdk/xdr/ledger_key_data.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .string64 import String64 - -__all__ = ["LedgerKeyData"] - - +__all__ = ['LedgerKeyData'] class LedgerKeyData: """ XDR Source Code:: @@ -22,7 +22,6 @@ class LedgerKeyData: string64 dataName; } """ - def __init__( self, account_id: AccountID, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.account_id = account_id self.data_name = data_name - def pack(self, packer: Packer) -> None: self.account_id.pack(packer) self.data_name.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyData: account_id = AccountID.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerKeyData: account_id=account_id, data_name=data_name, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyData: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.account_id, - self.data_name, - ) - ) - + return hash((self.account_id, self.data_name,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.account_id == other.account_id and self.data_name == other.data_name - + return self.account_id== other.account_id and self.data_name== other.data_name def __str__(self): out = [ - f"account_id={self.account_id}", - f"data_name={self.data_name}", + f'account_id={self.account_id}', + f'data_name={self.data_name}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_key_expiration.py b/stellar_sdk/xdr/ledger_key_expiration.py new file mode 100644 index 00000000..9e9bd85c --- /dev/null +++ b/stellar_sdk/xdr/ledger_key_expiration.py @@ -0,0 +1,65 @@ +# This is an automatically generated file. +# DO NOT EDIT or your changes may be overwritten +from __future__ import annotations + +import base64 +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING +from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * + +from .hash import Hash +__all__ = ['LedgerKeyExpiration'] +class LedgerKeyExpiration: + """ + XDR Source Code:: + + struct + { + // Hash of the LedgerKey that is associated with this ExpirationEntry + Hash keyHash; + } + """ + def __init__( + self, + key_hash: Hash, + ) -> None: + self.key_hash = key_hash + def pack(self, packer: Packer) -> None: + self.key_hash.pack(packer) + @classmethod + def unpack(cls, unpacker: Unpacker) -> LedgerKeyExpiration: + key_hash = Hash.unpack(unpacker) + return cls( + key_hash=key_hash, + ) + def to_xdr_bytes(self) -> bytes: + packer = Packer() + self.pack(packer) + return packer.get_buffer() + + @classmethod + def from_xdr_bytes(cls, xdr: bytes) -> LedgerKeyExpiration: + unpacker = Unpacker(xdr) + return cls.unpack(unpacker) + + def to_xdr(self) -> str: + xdr_bytes = self.to_xdr_bytes() + return base64.b64encode(xdr_bytes).decode() + + @classmethod + def from_xdr(cls, xdr: str) -> LedgerKeyExpiration: + xdr_bytes = base64.b64decode(xdr.encode()) + return cls.from_xdr_bytes(xdr_bytes) + def __hash__(self): + return hash((self.key_hash,)) + def __eq__(self, other: object): + if not isinstance(other, self.__class__): + return NotImplemented + return self.key_hash== other.key_hash + def __str__(self): + out = [ + f'key_hash={self.key_hash}', + ] + return f"" diff --git a/stellar_sdk/xdr/ledger_key_liquidity_pool.py b/stellar_sdk/xdr/ledger_key_liquidity_pool.py index b3a33a8b..efb0952a 100644 --- a/stellar_sdk/xdr/ledger_key_liquidity_pool.py +++ b/stellar_sdk/xdr/ledger_key_liquidity_pool.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .pool_id import PoolID - -__all__ = ["LedgerKeyLiquidityPool"] - - +__all__ = ['LedgerKeyLiquidityPool'] class LedgerKeyLiquidityPool: """ XDR Source Code:: @@ -20,23 +20,19 @@ class LedgerKeyLiquidityPool: PoolID liquidityPoolID; } """ - def __init__( self, liquidity_pool_id: PoolID, ) -> None: self.liquidity_pool_id = liquidity_pool_id - def pack(self, packer: Packer) -> None: self.liquidity_pool_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyLiquidityPool: liquidity_pool_id = PoolID.unpack(unpacker) return cls( liquidity_pool_id=liquidity_pool_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyLiquidityPool: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.liquidity_pool_id,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.liquidity_pool_id == other.liquidity_pool_id - + return self.liquidity_pool_id== other.liquidity_pool_id def __str__(self): out = [ - f"liquidity_pool_id={self.liquidity_pool_id}", + f'liquidity_pool_id={self.liquidity_pool_id}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_key_offer.py b/stellar_sdk/xdr/ledger_key_offer.py index 84903857..e6d19468 100644 --- a/stellar_sdk/xdr/ledger_key_offer.py +++ b/stellar_sdk/xdr/ledger_key_offer.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .int64 import Int64 - -__all__ = ["LedgerKeyOffer"] - - +__all__ = ['LedgerKeyOffer'] class LedgerKeyOffer: """ XDR Source Code:: @@ -22,7 +22,6 @@ class LedgerKeyOffer: int64 offerID; } """ - def __init__( self, seller_id: AccountID, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.seller_id = seller_id self.offer_id = offer_id - def pack(self, packer: Packer) -> None: self.seller_id.pack(packer) self.offer_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyOffer: seller_id = AccountID.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerKeyOffer: seller_id=seller_id, offer_id=offer_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyOffer: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.seller_id, - self.offer_id, - ) - ) - + return hash((self.seller_id, self.offer_id,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.seller_id == other.seller_id and self.offer_id == other.offer_id - + return self.seller_id== other.seller_id and self.offer_id== other.offer_id def __str__(self): out = [ - f"seller_id={self.seller_id}", - f"offer_id={self.offer_id}", + f'seller_id={self.seller_id}', + f'offer_id={self.offer_id}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_key_trust_line.py b/stellar_sdk/xdr/ledger_key_trust_line.py index 2774c171..884c6107 100644 --- a/stellar_sdk/xdr/ledger_key_trust_line.py +++ b/stellar_sdk/xdr/ledger_key_trust_line.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .trust_line_asset import TrustLineAsset - -__all__ = ["LedgerKeyTrustLine"] - - +__all__ = ['LedgerKeyTrustLine'] class LedgerKeyTrustLine: """ XDR Source Code:: @@ -22,7 +22,6 @@ class LedgerKeyTrustLine: TrustLineAsset asset; } """ - def __init__( self, account_id: AccountID, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.account_id = account_id self.asset = asset - def pack(self, packer: Packer) -> None: self.account_id.pack(packer) self.asset.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerKeyTrustLine: account_id = AccountID.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerKeyTrustLine: account_id=account_id, asset=asset, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerKeyTrustLine: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.account_id, - self.asset, - ) - ) - + return hash((self.account_id, self.asset,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.account_id == other.account_id and self.asset == other.asset - + return self.account_id== other.account_id and self.asset== other.asset def __str__(self): out = [ - f"account_id={self.account_id}", - f"asset={self.asset}", + f'account_id={self.account_id}', + f'asset={self.asset}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_scp_messages.py b/stellar_sdk/xdr/ledger_scp_messages.py index 6aba5de6..a07cd04a 100644 --- a/stellar_sdk/xdr/ledger_scp_messages.py +++ b/stellar_sdk/xdr/ledger_scp_messages.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .scp_envelope import SCPEnvelope from .uint32 import Uint32 - -__all__ = ["LedgerSCPMessages"] - - +from .scp_envelope import SCPEnvelope +__all__ = ['LedgerSCPMessages'] class LedgerSCPMessages: """ XDR Source Code:: @@ -23,7 +22,6 @@ class LedgerSCPMessages: SCPEnvelope messages<>; }; """ - def __init__( self, ledger_seq: Uint32, @@ -31,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if messages and len(messages) > _expect_max_length: - raise ValueError( - f"The maximum length of `messages` should be {_expect_max_length}, but got {len(messages)}." - ) + raise ValueError(f"The maximum length of `messages` should be {_expect_max_length}, but got {len(messages)}.") self.ledger_seq = ledger_seq self.messages = messages - def pack(self, packer: Packer) -> None: self.ledger_seq.pack(packer) packer.pack_uint(len(self.messages)) for messages_item in self.messages: messages_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerSCPMessages: ledger_seq = Uint32.unpack(unpacker) @@ -54,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> LedgerSCPMessages: ledger_seq=ledger_seq, messages=messages, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,23 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerSCPMessages: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_seq, - self.messages, - ) - ) - + return hash((self.ledger_seq, self.messages,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.ledger_seq == other.ledger_seq and self.messages == other.messages - + return self.ledger_seq== other.ledger_seq and self.messages== other.messages def __str__(self): out = [ - f"ledger_seq={self.ledger_seq}", - f"messages={self.messages}", + f'ledger_seq={self.ledger_seq}', + f'messages={self.messages}', ] return f"" diff --git a/stellar_sdk/xdr/ledger_upgrade.py b/stellar_sdk/xdr/ledger_upgrade.py index 092b70f7..db470e11 100644 --- a/stellar_sdk/xdr/ledger_upgrade.py +++ b/stellar_sdk/xdr/ledger_upgrade.py @@ -3,16 +3,21 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .config_upgrade_set_key import ConfigUpgradeSetKey from .ledger_upgrade_type import LedgerUpgradeType from .uint32 import Uint32 - -__all__ = ["LedgerUpgrade"] - - +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .config_upgrade_set_key import ConfigUpgradeSetKey +from .uint32 import Uint32 +__all__ = ['LedgerUpgrade'] class LedgerUpgrade: """ XDR Source Code:: @@ -38,7 +43,6 @@ class LedgerUpgrade: uint32 newMaxSorobanTxSetSize; }; """ - def __init__( self, type: LedgerUpgradeType, @@ -58,7 +62,6 @@ def __init__( self.new_flags = new_flags self.new_config = new_config self.new_max_soroban_tx_set_size = new_max_soroban_tx_set_size - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == LedgerUpgradeType.LEDGER_UPGRADE_VERSION: @@ -96,7 +99,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("new_max_soroban_tx_set_size should not be None.") self.new_max_soroban_tx_set_size.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LedgerUpgrade: type = LedgerUpgradeType.unpack(unpacker) @@ -120,11 +122,8 @@ def unpack(cls, unpacker: Unpacker) -> LedgerUpgrade: return cls(type=type, new_config=new_config) if type == LedgerUpgradeType.LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: new_max_soroban_tx_set_size = Uint32.unpack(unpacker) - return cls( - type=type, new_max_soroban_tx_set_size=new_max_soroban_tx_set_size - ) + return cls(type=type, new_max_soroban_tx_set_size=new_max_soroban_tx_set_size) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -143,57 +142,20 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LedgerUpgrade: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.new_ledger_version, - self.new_base_fee, - self.new_max_tx_set_size, - self.new_base_reserve, - self.new_flags, - self.new_config, - self.new_max_soroban_tx_set_size, - ) - ) - + return hash((self.type, self.new_ledger_version, self.new_base_fee, self.new_max_tx_set_size, self.new_base_reserve, self.new_flags, self.new_config, self.new_max_soroban_tx_set_size,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.new_ledger_version == other.new_ledger_version - and self.new_base_fee == other.new_base_fee - and self.new_max_tx_set_size == other.new_max_tx_set_size - and self.new_base_reserve == other.new_base_reserve - and self.new_flags == other.new_flags - and self.new_config == other.new_config - and self.new_max_soroban_tx_set_size == other.new_max_soroban_tx_set_size - ) - + return self.type== other.type and self.new_ledger_version== other.new_ledger_version and self.new_base_fee== other.new_base_fee and self.new_max_tx_set_size== other.new_max_tx_set_size and self.new_base_reserve== other.new_base_reserve and self.new_flags== other.new_flags and self.new_config== other.new_config and self.new_max_soroban_tx_set_size== other.new_max_soroban_tx_set_size def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"new_ledger_version={self.new_ledger_version}" - ) if self.new_ledger_version is not None else None - out.append( - f"new_base_fee={self.new_base_fee}" - ) if self.new_base_fee is not None else None - out.append( - f"new_max_tx_set_size={self.new_max_tx_set_size}" - ) if self.new_max_tx_set_size is not None else None - out.append( - f"new_base_reserve={self.new_base_reserve}" - ) if self.new_base_reserve is not None else None - out.append( - f"new_flags={self.new_flags}" - ) if self.new_flags is not None else None - out.append( - f"new_config={self.new_config}" - ) if self.new_config is not None else None - out.append( - f"new_max_soroban_tx_set_size={self.new_max_soroban_tx_set_size}" - ) if self.new_max_soroban_tx_set_size is not None else None + out.append(f'type={self.type}') + out.append(f'new_ledger_version={self.new_ledger_version}') if self.new_ledger_version is not None else None + out.append(f'new_base_fee={self.new_base_fee}') if self.new_base_fee is not None else None + out.append(f'new_max_tx_set_size={self.new_max_tx_set_size}') if self.new_max_tx_set_size is not None else None + out.append(f'new_base_reserve={self.new_base_reserve}') if self.new_base_reserve is not None else None + out.append(f'new_flags={self.new_flags}') if self.new_flags is not None else None + out.append(f'new_config={self.new_config}') if self.new_config is not None else None + out.append(f'new_max_soroban_tx_set_size={self.new_max_soroban_tx_set_size}') if self.new_max_soroban_tx_set_size is not None else None return f"" diff --git a/stellar_sdk/xdr/ledger_upgrade_type.py b/stellar_sdk/xdr/ledger_upgrade_type.py index 5441d7a8..6dd2b917 100644 --- a/stellar_sdk/xdr/ledger_upgrade_type.py +++ b/stellar_sdk/xdr/ledger_upgrade_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["LedgerUpgradeType"] - - +__all__ = ['LedgerUpgradeType'] class LedgerUpgradeType(IntEnum): """ XDR Source Code:: @@ -25,7 +25,6 @@ class LedgerUpgradeType(IntEnum): LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE = 7 }; """ - LEDGER_UPGRADE_VERSION = 1 LEDGER_UPGRADE_BASE_FEE = 2 LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3 @@ -33,7 +32,6 @@ class LedgerUpgradeType(IntEnum): LEDGER_UPGRADE_FLAGS = 5 LEDGER_UPGRADE_CONFIG = 6 LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE = 7 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -41,7 +39,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> LedgerUpgradeType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/liabilities.py b/stellar_sdk/xdr/liabilities.py index bcf862b4..fefdd2e3 100644 --- a/stellar_sdk/xdr/liabilities.py +++ b/stellar_sdk/xdr/liabilities.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int64 import Int64 - -__all__ = ["Liabilities"] - - +from .int64 import Int64 +__all__ = ['Liabilities'] class Liabilities: """ XDR Source Code:: @@ -21,7 +22,6 @@ class Liabilities: int64 selling; }; """ - def __init__( self, buying: Int64, @@ -29,11 +29,9 @@ def __init__( ) -> None: self.buying = buying self.selling = selling - def pack(self, packer: Packer) -> None: self.buying.pack(packer) self.selling.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Liabilities: buying = Int64.unpack(unpacker) @@ -42,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> Liabilities: buying=buying, selling=selling, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Liabilities: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.buying, - self.selling, - ) - ) - + return hash((self.buying, self.selling,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.buying == other.buying and self.selling == other.selling - + return self.buying== other.buying and self.selling== other.selling def __str__(self): out = [ - f"buying={self.buying}", - f"selling={self.selling}", + f'buying={self.buying}', + f'selling={self.selling}', ] return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_constant_product_parameters.py b/stellar_sdk/xdr/liquidity_pool_constant_product_parameters.py index 38e37302..a1c88bd2 100644 --- a/stellar_sdk/xdr/liquidity_pool_constant_product_parameters.py +++ b/stellar_sdk/xdr/liquidity_pool_constant_product_parameters.py @@ -3,15 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .asset import Asset from .asset import Asset from .int32 import Int32 - -__all__ = ["LiquidityPoolConstantProductParameters"] - - +__all__ = ['LiquidityPoolConstantProductParameters'] class LiquidityPoolConstantProductParameters: """ XDR Source Code:: @@ -23,7 +24,6 @@ class LiquidityPoolConstantProductParameters: int32 fee; // Fee is in basis points, so the actual rate is (fee/100)% }; """ - def __init__( self, asset_a: Asset, @@ -33,12 +33,10 @@ def __init__( self.asset_a = asset_a self.asset_b = asset_b self.fee = fee - def pack(self, packer: Packer) -> None: self.asset_a.pack(packer) self.asset_b.pack(packer) self.fee.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolConstantProductParameters: asset_a = Asset.unpack(unpacker) @@ -49,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolConstantProductParameters: asset_b=asset_b, fee=fee, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -68,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolConstantProductParameters: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.asset_a, - self.asset_b, - self.fee, - ) - ) - + return hash((self.asset_a, self.asset_b, self.fee,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.asset_a == other.asset_a - and self.asset_b == other.asset_b - and self.fee == other.fee - ) - + return self.asset_a== other.asset_a and self.asset_b== other.asset_b and self.fee== other.fee def __str__(self): out = [ - f"asset_a={self.asset_a}", - f"asset_b={self.asset_b}", - f"fee={self.fee}", + f'asset_a={self.asset_a}', + f'asset_b={self.asset_b}', + f'fee={self.fee}', ] return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_deposit_op.py b/stellar_sdk/xdr/liquidity_pool_deposit_op.py index 820313ad..42838295 100644 --- a/stellar_sdk/xdr/liquidity_pool_deposit_op.py +++ b/stellar_sdk/xdr/liquidity_pool_deposit_op.py @@ -3,16 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .int64 import Int64 from .pool_id import PoolID +from .int64 import Int64 +from .int64 import Int64 from .price import Price - -__all__ = ["LiquidityPoolDepositOp"] - - +from .price import Price +__all__ = ['LiquidityPoolDepositOp'] class LiquidityPoolDepositOp: """ XDR Source Code:: @@ -26,7 +28,6 @@ class LiquidityPoolDepositOp: Price maxPrice; // maximum depositA/depositB }; """ - def __init__( self, liquidity_pool_id: PoolID, @@ -40,14 +41,12 @@ def __init__( self.max_amount_b = max_amount_b self.min_price = min_price self.max_price = max_price - def pack(self, packer: Packer) -> None: self.liquidity_pool_id.pack(packer) self.max_amount_a.pack(packer) self.max_amount_b.pack(packer) self.min_price.pack(packer) self.max_price.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolDepositOp: liquidity_pool_id = PoolID.unpack(unpacker) @@ -62,7 +61,6 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolDepositOp: min_price=min_price, max_price=max_price, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -81,35 +79,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolDepositOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.liquidity_pool_id, - self.max_amount_a, - self.max_amount_b, - self.min_price, - self.max_price, - ) - ) - + return hash((self.liquidity_pool_id, self.max_amount_a, self.max_amount_b, self.min_price, self.max_price,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.liquidity_pool_id == other.liquidity_pool_id - and self.max_amount_a == other.max_amount_a - and self.max_amount_b == other.max_amount_b - and self.min_price == other.min_price - and self.max_price == other.max_price - ) - + return self.liquidity_pool_id== other.liquidity_pool_id and self.max_amount_a== other.max_amount_a and self.max_amount_b== other.max_amount_b and self.min_price== other.min_price and self.max_price== other.max_price def __str__(self): out = [ - f"liquidity_pool_id={self.liquidity_pool_id}", - f"max_amount_a={self.max_amount_a}", - f"max_amount_b={self.max_amount_b}", - f"min_price={self.min_price}", - f"max_price={self.max_price}", + f'liquidity_pool_id={self.liquidity_pool_id}', + f'max_amount_a={self.max_amount_a}', + f'max_amount_b={self.max_amount_b}', + f'min_price={self.min_price}', + f'max_price={self.max_price}', ] return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_deposit_result.py b/stellar_sdk/xdr/liquidity_pool_deposit_result.py index 10c858eb..1d444a76 100644 --- a/stellar_sdk/xdr/liquidity_pool_deposit_result.py +++ b/stellar_sdk/xdr/liquidity_pool_deposit_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .liquidity_pool_deposit_result_code import LiquidityPoolDepositResultCode - -__all__ = ["LiquidityPoolDepositResult"] - - +__all__ = ['LiquidityPoolDepositResult'] class LiquidityPoolDepositResult: """ XDR Source Code:: @@ -29,13 +29,11 @@ class LiquidityPoolDepositResult: void; }; """ - def __init__( self, code: LiquidityPoolDepositResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_SUCCESS: @@ -44,15 +42,9 @@ def pack(self, packer: Packer) -> None: return if self.code == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_NO_TRUST: return - if ( - self.code - == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED - ): + if self.code == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED: return - if ( - self.code - == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED - ): + if self.code == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED: return if self.code == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_LINE_FULL: return @@ -60,7 +52,6 @@ def pack(self, packer: Packer) -> None: return if self.code == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_POOL_FULL: return - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolDepositResult: code = LiquidityPoolDepositResultCode.unpack(unpacker) @@ -81,7 +72,6 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolDepositResult: if code == LiquidityPoolDepositResultCode.LIQUIDITY_POOL_DEPOSIT_POOL_FULL: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -100,16 +90,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolDepositResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_deposit_result_code.py b/stellar_sdk/xdr/liquidity_pool_deposit_result_code.py index 49290154..ac9a1b0e 100644 --- a/stellar_sdk/xdr/liquidity_pool_deposit_result_code.py +++ b/stellar_sdk/xdr/liquidity_pool_deposit_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["LiquidityPoolDepositResultCode"] - - +__all__ = ['LiquidityPoolDepositResultCode'] class LiquidityPoolDepositResultCode(IntEnum): """ XDR Source Code:: @@ -33,7 +33,6 @@ class LiquidityPoolDepositResultCode(IntEnum): LIQUIDITY_POOL_DEPOSIT_POOL_FULL = -7 // pool reserves are full }; """ - LIQUIDITY_POOL_DEPOSIT_SUCCESS = 0 LIQUIDITY_POOL_DEPOSIT_MALFORMED = -1 LIQUIDITY_POOL_DEPOSIT_NO_TRUST = -2 @@ -42,7 +41,6 @@ class LiquidityPoolDepositResultCode(IntEnum): LIQUIDITY_POOL_DEPOSIT_LINE_FULL = -5 LIQUIDITY_POOL_DEPOSIT_BAD_PRICE = -6 LIQUIDITY_POOL_DEPOSIT_POOL_FULL = -7 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -50,7 +48,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> LiquidityPoolDepositResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/liquidity_pool_entry.py b/stellar_sdk/xdr/liquidity_pool_entry.py index fbf0e7ca..786e8038 100644 --- a/stellar_sdk/xdr/liquidity_pool_entry.py +++ b/stellar_sdk/xdr/liquidity_pool_entry.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .liquidity_pool_entry_body import LiquidityPoolEntryBody from .pool_id import PoolID - -__all__ = ["LiquidityPoolEntry"] - - +from .liquidity_pool_entry_body import LiquidityPoolEntryBody +__all__ = ['LiquidityPoolEntry'] class LiquidityPoolEntry: """ XDR Source Code:: @@ -37,7 +37,6 @@ class LiquidityPoolEntry: body; }; """ - def __init__( self, liquidity_pool_id: PoolID, @@ -45,11 +44,9 @@ def __init__( ) -> None: self.liquidity_pool_id = liquidity_pool_id self.body = body - def pack(self, packer: Packer) -> None: self.liquidity_pool_id.pack(packer) self.body.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolEntry: liquidity_pool_id = PoolID.unpack(unpacker) @@ -58,7 +55,6 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolEntry: liquidity_pool_id=liquidity_pool_id, body=body, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -77,26 +73,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.liquidity_pool_id, - self.body, - ) - ) - + return hash((self.liquidity_pool_id, self.body,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.liquidity_pool_id == other.liquidity_pool_id - and self.body == other.body - ) - + return self.liquidity_pool_id== other.liquidity_pool_id and self.body== other.body def __str__(self): out = [ - f"liquidity_pool_id={self.liquidity_pool_id}", - f"body={self.body}", + f'liquidity_pool_id={self.liquidity_pool_id}', + f'body={self.body}', ] return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_entry_body.py b/stellar_sdk/xdr/liquidity_pool_entry_body.py index 312d1ce6..fa7dc645 100644 --- a/stellar_sdk/xdr/liquidity_pool_entry_body.py +++ b/stellar_sdk/xdr/liquidity_pool_entry_body.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .liquidity_pool_entry_constant_product import LiquidityPoolEntryConstantProduct from .liquidity_pool_type import LiquidityPoolType - -__all__ = ["LiquidityPoolEntryBody"] - - +from .liquidity_pool_entry_constant_product import LiquidityPoolEntryConstantProduct +__all__ = ['LiquidityPoolEntryBody'] class LiquidityPoolEntryBody: """ XDR Source Code:: @@ -31,7 +31,6 @@ class LiquidityPoolEntryBody: } constantProduct; } """ - def __init__( self, type: LiquidityPoolType, @@ -39,7 +38,6 @@ def __init__( ) -> None: self.type = type self.constant_product = constant_product - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == LiquidityPoolType.LIQUIDITY_POOL_CONSTANT_PRODUCT: @@ -47,7 +45,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("constant_product should not be None.") self.constant_product.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolEntryBody: type = LiquidityPoolType.unpack(unpacker) @@ -55,7 +52,6 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolEntryBody: constant_product = LiquidityPoolEntryConstantProduct.unpack(unpacker) return cls(type=type, constant_product=constant_product) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -74,26 +70,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolEntryBody: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.constant_product, - ) - ) - + return hash((self.type, self.constant_product,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type and self.constant_product == other.constant_product - ) - + return self.type== other.type and self.constant_product== other.constant_product def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"constant_product={self.constant_product}" - ) if self.constant_product is not None else None + out.append(f'type={self.type}') + out.append(f'constant_product={self.constant_product}') if self.constant_product is not None else None return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_entry_constant_product.py b/stellar_sdk/xdr/liquidity_pool_entry_constant_product.py index 0e57f186..ae42da22 100644 --- a/stellar_sdk/xdr/liquidity_pool_entry_constant_product.py +++ b/stellar_sdk/xdr/liquidity_pool_entry_constant_product.py @@ -3,17 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .liquidity_pool_constant_product_parameters import LiquidityPoolConstantProductParameters from .int64 import Int64 -from .liquidity_pool_constant_product_parameters import ( - LiquidityPoolConstantProductParameters, -) - -__all__ = ["LiquidityPoolEntryConstantProduct"] - - +from .int64 import Int64 +from .int64 import Int64 +from .int64 import Int64 +__all__ = ['LiquidityPoolEntryConstantProduct'] class LiquidityPoolEntryConstantProduct: """ XDR Source Code:: @@ -29,7 +30,6 @@ class LiquidityPoolEntryConstantProduct: // associated pool shares } """ - def __init__( self, params: LiquidityPoolConstantProductParameters, @@ -43,14 +43,12 @@ def __init__( self.reserve_b = reserve_b self.total_pool_shares = total_pool_shares self.pool_shares_trust_line_count = pool_shares_trust_line_count - def pack(self, packer: Packer) -> None: self.params.pack(packer) self.reserve_a.pack(packer) self.reserve_b.pack(packer) self.total_pool_shares.pack(packer) self.pool_shares_trust_line_count.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolEntryConstantProduct: params = LiquidityPoolConstantProductParameters.unpack(unpacker) @@ -65,7 +63,6 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolEntryConstantProduct: total_pool_shares=total_pool_shares, pool_shares_trust_line_count=pool_shares_trust_line_count, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -84,35 +81,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolEntryConstantProduct: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.params, - self.reserve_a, - self.reserve_b, - self.total_pool_shares, - self.pool_shares_trust_line_count, - ) - ) - + return hash((self.params, self.reserve_a, self.reserve_b, self.total_pool_shares, self.pool_shares_trust_line_count,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.params == other.params - and self.reserve_a == other.reserve_a - and self.reserve_b == other.reserve_b - and self.total_pool_shares == other.total_pool_shares - and self.pool_shares_trust_line_count == other.pool_shares_trust_line_count - ) - + return self.params== other.params and self.reserve_a== other.reserve_a and self.reserve_b== other.reserve_b and self.total_pool_shares== other.total_pool_shares and self.pool_shares_trust_line_count== other.pool_shares_trust_line_count def __str__(self): out = [ - f"params={self.params}", - f"reserve_a={self.reserve_a}", - f"reserve_b={self.reserve_b}", - f"total_pool_shares={self.total_pool_shares}", - f"pool_shares_trust_line_count={self.pool_shares_trust_line_count}", + f'params={self.params}', + f'reserve_a={self.reserve_a}', + f'reserve_b={self.reserve_b}', + f'total_pool_shares={self.total_pool_shares}', + f'pool_shares_trust_line_count={self.pool_shares_trust_line_count}', ] return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_parameters.py b/stellar_sdk/xdr/liquidity_pool_parameters.py index 70f62c47..605e283c 100644 --- a/stellar_sdk/xdr/liquidity_pool_parameters.py +++ b/stellar_sdk/xdr/liquidity_pool_parameters.py @@ -3,17 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .liquidity_pool_constant_product_parameters import ( - LiquidityPoolConstantProductParameters, -) from .liquidity_pool_type import LiquidityPoolType - -__all__ = ["LiquidityPoolParameters"] - - +from .liquidity_pool_constant_product_parameters import LiquidityPoolConstantProductParameters +__all__ = ['LiquidityPoolParameters'] class LiquidityPoolParameters: """ XDR Source Code:: @@ -24,7 +22,6 @@ class LiquidityPoolParameters: LiquidityPoolConstantProductParameters constantProduct; }; """ - def __init__( self, type: LiquidityPoolType, @@ -32,7 +29,6 @@ def __init__( ) -> None: self.type = type self.constant_product = constant_product - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == LiquidityPoolType.LIQUIDITY_POOL_CONSTANT_PRODUCT: @@ -40,7 +36,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("constant_product should not be None.") self.constant_product.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolParameters: type = LiquidityPoolType.unpack(unpacker) @@ -48,7 +43,6 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolParameters: constant_product = LiquidityPoolConstantProductParameters.unpack(unpacker) return cls(type=type, constant_product=constant_product) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -67,26 +61,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolParameters: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.constant_product, - ) - ) - + return hash((self.type, self.constant_product,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type and self.constant_product == other.constant_product - ) - + return self.type== other.type and self.constant_product== other.constant_product def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"constant_product={self.constant_product}" - ) if self.constant_product is not None else None + out.append(f'type={self.type}') + out.append(f'constant_product={self.constant_product}') if self.constant_product is not None else None return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_type.py b/stellar_sdk/xdr/liquidity_pool_type.py index 86181ef6..a2a195f8 100644 --- a/stellar_sdk/xdr/liquidity_pool_type.py +++ b/stellar_sdk/xdr/liquidity_pool_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["LiquidityPoolType"] - - +__all__ = ['LiquidityPoolType'] class LiquidityPoolType(IntEnum): """ XDR Source Code:: @@ -19,9 +19,7 @@ class LiquidityPoolType(IntEnum): LIQUIDITY_POOL_CONSTANT_PRODUCT = 0 }; """ - LIQUIDITY_POOL_CONSTANT_PRODUCT = 0 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -29,7 +27,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> LiquidityPoolType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/liquidity_pool_withdraw_op.py b/stellar_sdk/xdr/liquidity_pool_withdraw_op.py index daf02451..4fe443d4 100644 --- a/stellar_sdk/xdr/liquidity_pool_withdraw_op.py +++ b/stellar_sdk/xdr/liquidity_pool_withdraw_op.py @@ -3,15 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .int64 import Int64 from .pool_id import PoolID - -__all__ = ["LiquidityPoolWithdrawOp"] - - +from .int64 import Int64 +from .int64 import Int64 +from .int64 import Int64 +__all__ = ['LiquidityPoolWithdrawOp'] class LiquidityPoolWithdrawOp: """ XDR Source Code:: @@ -24,7 +26,6 @@ class LiquidityPoolWithdrawOp: int64 minAmountB; // minimum amount of second asset to withdraw }; """ - def __init__( self, liquidity_pool_id: PoolID, @@ -36,13 +37,11 @@ def __init__( self.amount = amount self.min_amount_a = min_amount_a self.min_amount_b = min_amount_b - def pack(self, packer: Packer) -> None: self.liquidity_pool_id.pack(packer) self.amount.pack(packer) self.min_amount_a.pack(packer) self.min_amount_b.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolWithdrawOp: liquidity_pool_id = PoolID.unpack(unpacker) @@ -55,7 +54,6 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolWithdrawOp: min_amount_a=min_amount_a, min_amount_b=min_amount_b, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -74,32 +72,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolWithdrawOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.liquidity_pool_id, - self.amount, - self.min_amount_a, - self.min_amount_b, - ) - ) - + return hash((self.liquidity_pool_id, self.amount, self.min_amount_a, self.min_amount_b,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.liquidity_pool_id == other.liquidity_pool_id - and self.amount == other.amount - and self.min_amount_a == other.min_amount_a - and self.min_amount_b == other.min_amount_b - ) - + return self.liquidity_pool_id== other.liquidity_pool_id and self.amount== other.amount and self.min_amount_a== other.min_amount_a and self.min_amount_b== other.min_amount_b def __str__(self): out = [ - f"liquidity_pool_id={self.liquidity_pool_id}", - f"amount={self.amount}", - f"min_amount_a={self.min_amount_a}", - f"min_amount_b={self.min_amount_b}", + f'liquidity_pool_id={self.liquidity_pool_id}', + f'amount={self.amount}', + f'min_amount_a={self.min_amount_a}', + f'min_amount_b={self.min_amount_b}', ] return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_withdraw_result.py b/stellar_sdk/xdr/liquidity_pool_withdraw_result.py index 51da190f..13ab9e67 100644 --- a/stellar_sdk/xdr/liquidity_pool_withdraw_result.py +++ b/stellar_sdk/xdr/liquidity_pool_withdraw_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .liquidity_pool_withdraw_result_code import LiquidityPoolWithdrawResultCode - -__all__ = ["LiquidityPoolWithdrawResult"] - - +__all__ = ['LiquidityPoolWithdrawResult'] class LiquidityPoolWithdrawResult: """ XDR Source Code:: @@ -27,43 +27,25 @@ class LiquidityPoolWithdrawResult: void; }; """ - def __init__( self, code: LiquidityPoolWithdrawResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_SUCCESS: return - if ( - self.code - == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_MALFORMED - ): + if self.code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_MALFORMED: return - if ( - self.code - == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_NO_TRUST - ): + if self.code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_NO_TRUST: return - if ( - self.code - == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED - ): + if self.code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED: return - if ( - self.code - == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_LINE_FULL - ): + if self.code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_LINE_FULL: return - if ( - self.code - == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM - ): + if self.code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM: return - @classmethod def unpack(cls, unpacker: Unpacker) -> LiquidityPoolWithdrawResult: code = LiquidityPoolWithdrawResultCode.unpack(unpacker) @@ -77,13 +59,9 @@ def unpack(cls, unpacker: Unpacker) -> LiquidityPoolWithdrawResult: return cls(code=code) if code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_LINE_FULL: return cls(code=code) - if ( - code - == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM - ): + if code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,16 +80,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> LiquidityPoolWithdrawResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/liquidity_pool_withdraw_result_code.py b/stellar_sdk/xdr/liquidity_pool_withdraw_result_code.py index 4c5a74b5..3bb0debe 100644 --- a/stellar_sdk/xdr/liquidity_pool_withdraw_result_code.py +++ b/stellar_sdk/xdr/liquidity_pool_withdraw_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["LiquidityPoolWithdrawResultCode"] - - +__all__ = ['LiquidityPoolWithdrawResultCode'] class LiquidityPoolWithdrawResultCode(IntEnum): """ XDR Source Code:: @@ -30,14 +30,12 @@ class LiquidityPoolWithdrawResultCode(IntEnum): LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM = -5 // didn't withdraw enough }; """ - LIQUIDITY_POOL_WITHDRAW_SUCCESS = 0 LIQUIDITY_POOL_WITHDRAW_MALFORMED = -1 LIQUIDITY_POOL_WITHDRAW_NO_TRUST = -2 LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED = -3 LIQUIDITY_POOL_WITHDRAW_LINE_FULL = -4 LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM = -5 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -45,7 +43,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> LiquidityPoolWithdrawResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/manage_buy_offer_op.py b/stellar_sdk/xdr/manage_buy_offer_op.py index 87a328dc..f3ed6453 100644 --- a/stellar_sdk/xdr/manage_buy_offer_op.py +++ b/stellar_sdk/xdr/manage_buy_offer_op.py @@ -3,16 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .asset import Asset from .asset import Asset from .int64 import Int64 from .price import Price - -__all__ = ["ManageBuyOfferOp"] - - +from .int64 import Int64 +__all__ = ['ManageBuyOfferOp'] class ManageBuyOfferOp: """ XDR Source Code:: @@ -29,7 +31,6 @@ class ManageBuyOfferOp: int64 offerID; }; """ - def __init__( self, selling: Asset, @@ -43,14 +44,12 @@ def __init__( self.buy_amount = buy_amount self.price = price self.offer_id = offer_id - def pack(self, packer: Packer) -> None: self.selling.pack(packer) self.buying.pack(packer) self.buy_amount.pack(packer) self.price.pack(packer) self.offer_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ManageBuyOfferOp: selling = Asset.unpack(unpacker) @@ -65,7 +64,6 @@ def unpack(cls, unpacker: Unpacker) -> ManageBuyOfferOp: price=price, offer_id=offer_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -84,35 +82,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ManageBuyOfferOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.selling, - self.buying, - self.buy_amount, - self.price, - self.offer_id, - ) - ) - + return hash((self.selling, self.buying, self.buy_amount, self.price, self.offer_id,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.selling == other.selling - and self.buying == other.buying - and self.buy_amount == other.buy_amount - and self.price == other.price - and self.offer_id == other.offer_id - ) - + return self.selling== other.selling and self.buying== other.buying and self.buy_amount== other.buy_amount and self.price== other.price and self.offer_id== other.offer_id def __str__(self): out = [ - f"selling={self.selling}", - f"buying={self.buying}", - f"buy_amount={self.buy_amount}", - f"price={self.price}", - f"offer_id={self.offer_id}", + f'selling={self.selling}', + f'buying={self.buying}', + f'buy_amount={self.buy_amount}', + f'price={self.price}', + f'offer_id={self.offer_id}', ] return f"" diff --git a/stellar_sdk/xdr/manage_buy_offer_result.py b/stellar_sdk/xdr/manage_buy_offer_result.py index 856c997a..472d313f 100644 --- a/stellar_sdk/xdr/manage_buy_offer_result.py +++ b/stellar_sdk/xdr/manage_buy_offer_result.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .manage_buy_offer_result_code import ManageBuyOfferResultCode from .manage_offer_success_result import ManageOfferSuccessResult - -__all__ = ["ManageBuyOfferResult"] - - +__all__ = ['ManageBuyOfferResult'] class ManageBuyOfferResult: """ XDR Source Code:: @@ -35,7 +35,6 @@ class ManageBuyOfferResult: void; }; """ - def __init__( self, code: ManageBuyOfferResultCode, @@ -43,7 +42,6 @@ def __init__( ) -> None: self.code = code self.success = success - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == ManageBuyOfferResultCode.MANAGE_BUY_OFFER_SUCCESS: @@ -75,7 +73,6 @@ def pack(self, packer: Packer) -> None: return if self.code == ManageBuyOfferResultCode.MANAGE_BUY_OFFER_LOW_RESERVE: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ManageBuyOfferResult: code = ManageBuyOfferResultCode.unpack(unpacker) @@ -107,7 +104,6 @@ def unpack(cls, unpacker: Unpacker) -> ManageBuyOfferResult: if code == ManageBuyOfferResultCode.MANAGE_BUY_OFFER_LOW_RESERVE: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -126,22 +122,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ManageBuyOfferResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.success, - ) - ) - + return hash((self.code, self.success,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code and self.success == other.success - + return self.code== other.code and self.success== other.success def __str__(self): out = [] - out.append(f"code={self.code}") - out.append(f"success={self.success}") if self.success is not None else None + out.append(f'code={self.code}') + out.append(f'success={self.success}') if self.success is not None else None return f"" diff --git a/stellar_sdk/xdr/manage_buy_offer_result_code.py b/stellar_sdk/xdr/manage_buy_offer_result_code.py index 0608e1fa..5feadbb2 100644 --- a/stellar_sdk/xdr/manage_buy_offer_result_code.py +++ b/stellar_sdk/xdr/manage_buy_offer_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ManageBuyOfferResultCode"] - - +__all__ = ['ManageBuyOfferResultCode'] class ManageBuyOfferResultCode(IntEnum): """ XDR Source Code:: @@ -38,7 +38,6 @@ class ManageBuyOfferResultCode(IntEnum): MANAGE_BUY_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer }; """ - MANAGE_BUY_OFFER_SUCCESS = 0 MANAGE_BUY_OFFER_MALFORMED = -1 MANAGE_BUY_OFFER_SELL_NO_TRUST = -2 @@ -52,7 +51,6 @@ class ManageBuyOfferResultCode(IntEnum): MANAGE_BUY_OFFER_BUY_NO_ISSUER = -10 MANAGE_BUY_OFFER_NOT_FOUND = -11 MANAGE_BUY_OFFER_LOW_RESERVE = -12 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -60,7 +58,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ManageBuyOfferResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/manage_data_op.py b/stellar_sdk/xdr/manage_data_op.py index 092861b7..00ac4069 100644 --- a/stellar_sdk/xdr/manage_data_op.py +++ b/stellar_sdk/xdr/manage_data_op.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .data_value import DataValue from .string64 import String64 - -__all__ = ["ManageDataOp"] - - +from .data_value import DataValue +__all__ = ['ManageDataOp'] class ManageDataOp: """ XDR Source Code:: @@ -23,7 +22,6 @@ class ManageDataOp: DataValue* dataValue; // set to null to clear }; """ - def __init__( self, data_name: String64, @@ -31,7 +29,6 @@ def __init__( ) -> None: self.data_name = data_name self.data_value = data_value - def pack(self, packer: Packer) -> None: self.data_name.pack(packer) if self.data_value is None: @@ -39,7 +36,6 @@ def pack(self, packer: Packer) -> None: else: packer.pack_uint(1) self.data_value.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ManageDataOp: data_name = String64.unpack(unpacker) @@ -48,7 +44,6 @@ def unpack(cls, unpacker: Unpacker) -> ManageDataOp: data_name=data_name, data_value=data_value, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -67,23 +62,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ManageDataOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.data_name, - self.data_value, - ) - ) - + return hash((self.data_name, self.data_value,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.data_name == other.data_name and self.data_value == other.data_value - + return self.data_name== other.data_name and self.data_value== other.data_value def __str__(self): out = [ - f"data_name={self.data_name}", - f"data_value={self.data_value}", + f'data_name={self.data_name}', + f'data_value={self.data_value}', ] return f"" diff --git a/stellar_sdk/xdr/manage_data_result.py b/stellar_sdk/xdr/manage_data_result.py index 9f8747b1..d146d4b9 100644 --- a/stellar_sdk/xdr/manage_data_result.py +++ b/stellar_sdk/xdr/manage_data_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .manage_data_result_code import ManageDataResultCode - -__all__ = ["ManageDataResult"] - - +__all__ = ['ManageDataResult'] class ManageDataResult: """ XDR Source Code:: @@ -26,13 +26,11 @@ class ManageDataResult: void; }; """ - def __init__( self, code: ManageDataResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == ManageDataResultCode.MANAGE_DATA_SUCCESS: @@ -45,7 +43,6 @@ def pack(self, packer: Packer) -> None: return if self.code == ManageDataResultCode.MANAGE_DATA_INVALID_NAME: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ManageDataResult: code = ManageDataResultCode.unpack(unpacker) @@ -60,7 +57,6 @@ def unpack(cls, unpacker: Unpacker) -> ManageDataResult: if code == ManageDataResultCode.MANAGE_DATA_INVALID_NAME: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -79,16 +75,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ManageDataResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/manage_data_result_code.py b/stellar_sdk/xdr/manage_data_result_code.py index e02e0a08..8d32a7a0 100644 --- a/stellar_sdk/xdr/manage_data_result_code.py +++ b/stellar_sdk/xdr/manage_data_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ManageDataResultCode"] - - +__all__ = ['ManageDataResultCode'] class ManageDataResultCode(IntEnum): """ XDR Source Code:: @@ -27,13 +27,11 @@ class ManageDataResultCode(IntEnum): MANAGE_DATA_INVALID_NAME = -4 // Name not a valid string }; """ - MANAGE_DATA_SUCCESS = 0 MANAGE_DATA_NOT_SUPPORTED_YET = -1 MANAGE_DATA_NAME_NOT_FOUND = -2 MANAGE_DATA_LOW_RESERVE = -3 MANAGE_DATA_INVALID_NAME = -4 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -41,7 +39,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ManageDataResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/manage_offer_effect.py b/stellar_sdk/xdr/manage_offer_effect.py index 2c19e123..b2fb1ef5 100644 --- a/stellar_sdk/xdr/manage_offer_effect.py +++ b/stellar_sdk/xdr/manage_offer_effect.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ManageOfferEffect"] - - +__all__ = ['ManageOfferEffect'] class ManageOfferEffect(IntEnum): """ XDR Source Code:: @@ -21,11 +21,9 @@ class ManageOfferEffect(IntEnum): MANAGE_OFFER_DELETED = 2 }; """ - MANAGE_OFFER_CREATED = 0 MANAGE_OFFER_UPDATED = 1 MANAGE_OFFER_DELETED = 2 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -33,7 +31,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ManageOfferEffect: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/manage_offer_success_result.py b/stellar_sdk/xdr/manage_offer_success_result.py index b337a1aa..a38c6c8c 100644 --- a/stellar_sdk/xdr/manage_offer_success_result.py +++ b/stellar_sdk/xdr/manage_offer_success_result.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claim_atom import ClaimAtom from .manage_offer_success_result_offer import ManageOfferSuccessResultOffer - -__all__ = ["ManageOfferSuccessResult"] - - +__all__ = ['ManageOfferSuccessResult'] class ManageOfferSuccessResult: """ XDR Source Code:: @@ -33,7 +32,6 @@ class ManageOfferSuccessResult: offer; }; """ - def __init__( self, offers_claimed: List[ClaimAtom], @@ -41,18 +39,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if offers_claimed and len(offers_claimed) > _expect_max_length: - raise ValueError( - f"The maximum length of `offers_claimed` should be {_expect_max_length}, but got {len(offers_claimed)}." - ) + raise ValueError(f"The maximum length of `offers_claimed` should be {_expect_max_length}, but got {len(offers_claimed)}.") self.offers_claimed = offers_claimed self.offer = offer - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.offers_claimed)) for offers_claimed_item in self.offers_claimed: offers_claimed_item.pack(packer) self.offer.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ManageOfferSuccessResult: length = unpacker.unpack_uint() @@ -64,7 +58,6 @@ def unpack(cls, unpacker: Unpacker) -> ManageOfferSuccessResult: offers_claimed=offers_claimed, offer=offer, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -83,23 +76,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ManageOfferSuccessResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.offers_claimed, - self.offer, - ) - ) - + return hash((self.offers_claimed, self.offer,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.offers_claimed == other.offers_claimed and self.offer == other.offer - + return self.offers_claimed== other.offers_claimed and self.offer== other.offer def __str__(self): out = [ - f"offers_claimed={self.offers_claimed}", - f"offer={self.offer}", + f'offers_claimed={self.offers_claimed}', + f'offer={self.offer}', ] return f"" diff --git a/stellar_sdk/xdr/manage_offer_success_result_offer.py b/stellar_sdk/xdr/manage_offer_success_result_offer.py index 78f4a07b..567bfad7 100644 --- a/stellar_sdk/xdr/manage_offer_success_result_offer.py +++ b/stellar_sdk/xdr/manage_offer_success_result_offer.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .manage_offer_effect import ManageOfferEffect from .offer_entry import OfferEntry - -__all__ = ["ManageOfferSuccessResultOffer"] - - +__all__ = ['ManageOfferSuccessResultOffer'] class ManageOfferSuccessResultOffer: """ XDR Source Code:: @@ -25,7 +25,6 @@ class ManageOfferSuccessResultOffer: void; } """ - def __init__( self, effect: ManageOfferEffect, @@ -33,7 +32,6 @@ def __init__( ) -> None: self.effect = effect self.offer = offer - def pack(self, packer: Packer) -> None: self.effect.pack(packer) if self.effect == ManageOfferEffect.MANAGE_OFFER_CREATED: @@ -48,7 +46,6 @@ def pack(self, packer: Packer) -> None: return if self.effect == ManageOfferEffect.MANAGE_OFFER_DELETED: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ManageOfferSuccessResultOffer: effect = ManageOfferEffect.unpack(unpacker) @@ -61,7 +58,6 @@ def unpack(cls, unpacker: Unpacker) -> ManageOfferSuccessResultOffer: if effect == ManageOfferEffect.MANAGE_OFFER_DELETED: return cls(effect=effect) return cls(effect=effect) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -80,22 +76,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ManageOfferSuccessResultOffer: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.effect, - self.offer, - ) - ) - + return hash((self.effect, self.offer,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.effect == other.effect and self.offer == other.offer - + return self.effect== other.effect and self.offer== other.offer def __str__(self): out = [] - out.append(f"effect={self.effect}") - out.append(f"offer={self.offer}") if self.offer is not None else None + out.append(f'effect={self.effect}') + out.append(f'offer={self.offer}') if self.offer is not None else None return f"" diff --git a/stellar_sdk/xdr/manage_sell_offer_op.py b/stellar_sdk/xdr/manage_sell_offer_op.py index 6a8e2d55..34658a4a 100644 --- a/stellar_sdk/xdr/manage_sell_offer_op.py +++ b/stellar_sdk/xdr/manage_sell_offer_op.py @@ -3,16 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .asset import Asset from .asset import Asset from .int64 import Int64 from .price import Price - -__all__ = ["ManageSellOfferOp"] - - +from .int64 import Int64 +__all__ = ['ManageSellOfferOp'] class ManageSellOfferOp: """ XDR Source Code:: @@ -28,7 +30,6 @@ class ManageSellOfferOp: int64 offerID; }; """ - def __init__( self, selling: Asset, @@ -42,14 +43,12 @@ def __init__( self.amount = amount self.price = price self.offer_id = offer_id - def pack(self, packer: Packer) -> None: self.selling.pack(packer) self.buying.pack(packer) self.amount.pack(packer) self.price.pack(packer) self.offer_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> ManageSellOfferOp: selling = Asset.unpack(unpacker) @@ -64,7 +63,6 @@ def unpack(cls, unpacker: Unpacker) -> ManageSellOfferOp: price=price, offer_id=offer_id, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -83,35 +81,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ManageSellOfferOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.selling, - self.buying, - self.amount, - self.price, - self.offer_id, - ) - ) - + return hash((self.selling, self.buying, self.amount, self.price, self.offer_id,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.selling == other.selling - and self.buying == other.buying - and self.amount == other.amount - and self.price == other.price - and self.offer_id == other.offer_id - ) - + return self.selling== other.selling and self.buying== other.buying and self.amount== other.amount and self.price== other.price and self.offer_id== other.offer_id def __str__(self): out = [ - f"selling={self.selling}", - f"buying={self.buying}", - f"amount={self.amount}", - f"price={self.price}", - f"offer_id={self.offer_id}", + f'selling={self.selling}', + f'buying={self.buying}', + f'amount={self.amount}', + f'price={self.price}', + f'offer_id={self.offer_id}', ] return f"" diff --git a/stellar_sdk/xdr/manage_sell_offer_result.py b/stellar_sdk/xdr/manage_sell_offer_result.py index 08ef715e..b5684315 100644 --- a/stellar_sdk/xdr/manage_sell_offer_result.py +++ b/stellar_sdk/xdr/manage_sell_offer_result.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .manage_offer_success_result import ManageOfferSuccessResult from .manage_sell_offer_result_code import ManageSellOfferResultCode - -__all__ = ["ManageSellOfferResult"] - - +from .manage_offer_success_result import ManageOfferSuccessResult +__all__ = ['ManageSellOfferResult'] class ManageSellOfferResult: """ XDR Source Code:: @@ -35,7 +35,6 @@ class ManageSellOfferResult: void; }; """ - def __init__( self, code: ManageSellOfferResultCode, @@ -43,7 +42,6 @@ def __init__( ) -> None: self.code = code self.success = success - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == ManageSellOfferResultCode.MANAGE_SELL_OFFER_SUCCESS: @@ -75,7 +73,6 @@ def pack(self, packer: Packer) -> None: return if self.code == ManageSellOfferResultCode.MANAGE_SELL_OFFER_LOW_RESERVE: return - @classmethod def unpack(cls, unpacker: Unpacker) -> ManageSellOfferResult: code = ManageSellOfferResultCode.unpack(unpacker) @@ -107,7 +104,6 @@ def unpack(cls, unpacker: Unpacker) -> ManageSellOfferResult: if code == ManageSellOfferResultCode.MANAGE_SELL_OFFER_LOW_RESERVE: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -126,22 +122,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> ManageSellOfferResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.success, - ) - ) - + return hash((self.code, self.success,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code and self.success == other.success - + return self.code== other.code and self.success== other.success def __str__(self): out = [] - out.append(f"code={self.code}") - out.append(f"success={self.success}") if self.success is not None else None + out.append(f'code={self.code}') + out.append(f'success={self.success}') if self.success is not None else None return f"" diff --git a/stellar_sdk/xdr/manage_sell_offer_result_code.py b/stellar_sdk/xdr/manage_sell_offer_result_code.py index 95b6801e..9712910a 100644 --- a/stellar_sdk/xdr/manage_sell_offer_result_code.py +++ b/stellar_sdk/xdr/manage_sell_offer_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ManageSellOfferResultCode"] - - +__all__ = ['ManageSellOfferResultCode'] class ManageSellOfferResultCode(IntEnum): """ XDR Source Code:: @@ -41,7 +41,6 @@ class ManageSellOfferResultCode(IntEnum): -12 // not enough funds to create a new Offer }; """ - MANAGE_SELL_OFFER_SUCCESS = 0 MANAGE_SELL_OFFER_MALFORMED = -1 MANAGE_SELL_OFFER_SELL_NO_TRUST = -2 @@ -55,7 +54,6 @@ class ManageSellOfferResultCode(IntEnum): MANAGE_SELL_OFFER_BUY_NO_ISSUER = -10 MANAGE_SELL_OFFER_NOT_FOUND = -11 MANAGE_SELL_OFFER_LOW_RESERVE = -12 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -63,7 +61,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ManageSellOfferResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/memo.py b/stellar_sdk/xdr/memo.py index 0f332d42..ca30d690 100644 --- a/stellar_sdk/xdr/memo.py +++ b/stellar_sdk/xdr/memo.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import String -from .hash import Hash from .memo_type import MemoType from .uint64 import Uint64 - -__all__ = ["Memo"] - - +from .hash import Hash +from .hash import Hash +__all__ = ['Memo'] class Memo: """ XDR Source Code:: @@ -32,7 +32,6 @@ class Memo: Hash retHash; // the hash of the tx you are rejecting }; """ - def __init__( self, type: MemoType, @@ -46,7 +45,6 @@ def __init__( self.id = id self.hash = hash self.ret_hash = ret_hash - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == MemoType.MEMO_NONE: @@ -71,7 +69,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("ret_hash should not be None.") self.ret_hash.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> Memo: type = MemoType.unpack(unpacker) @@ -90,7 +87,6 @@ def unpack(cls, unpacker: Unpacker) -> Memo: ret_hash = Hash.unpack(unpacker) return cls(type=type, ret_hash=ret_hash) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -109,34 +105,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Memo: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.text, - self.id, - self.hash, - self.ret_hash, - ) - ) - + return hash((self.type, self.text, self.id, self.hash, self.ret_hash,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.text == other.text - and self.id == other.id - and self.hash == other.hash - and self.ret_hash == other.ret_hash - ) - + return self.type== other.type and self.text== other.text and self.id== other.id and self.hash== other.hash and self.ret_hash== other.ret_hash def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"text={self.text}") if self.text is not None else None - out.append(f"id={self.id}") if self.id is not None else None - out.append(f"hash={self.hash}") if self.hash is not None else None - out.append(f"ret_hash={self.ret_hash}") if self.ret_hash is not None else None + out.append(f'type={self.type}') + out.append(f'text={self.text}') if self.text is not None else None + out.append(f'id={self.id}') if self.id is not None else None + out.append(f'hash={self.hash}') if self.hash is not None else None + out.append(f'ret_hash={self.ret_hash}') if self.ret_hash is not None else None return f"" diff --git a/stellar_sdk/xdr/memo_type.py b/stellar_sdk/xdr/memo_type.py index c279e79b..c0fa6afb 100644 --- a/stellar_sdk/xdr/memo_type.py +++ b/stellar_sdk/xdr/memo_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["MemoType"] - - +__all__ = ['MemoType'] class MemoType(IntEnum): """ XDR Source Code:: @@ -23,13 +23,11 @@ class MemoType(IntEnum): MEMO_RETURN = 4 }; """ - MEMO_NONE = 0 MEMO_TEXT = 1 MEMO_ID = 2 MEMO_HASH = 3 MEMO_RETURN = 4 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -37,7 +35,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> MemoType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/message_type.py b/stellar_sdk/xdr/message_type.py index 20c60393..7f097349 100644 --- a/stellar_sdk/xdr/message_type.py +++ b/stellar_sdk/xdr/message_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["MessageType"] - - +__all__ = ['MessageType'] class MessageType(IntEnum): """ XDR Source Code:: @@ -48,7 +48,6 @@ class MessageType(IntEnum): FLOOD_DEMAND = 19 }; """ - ERROR_MSG = 0 AUTH = 2 DONT_HAVE = 3 @@ -69,7 +68,6 @@ class MessageType(IntEnum): SEND_MORE_EXTENDED = 20 FLOOD_ADVERT = 18 FLOOD_DEMAND = 19 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -77,7 +75,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> MessageType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/muxed_account.py b/stellar_sdk/xdr/muxed_account.py index 44a172e3..dd17a662 100644 --- a/stellar_sdk/xdr/muxed_account.py +++ b/stellar_sdk/xdr/muxed_account.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .crypto_key_type import CryptoKeyType -from .muxed_account_med25519 import MuxedAccountMed25519 from .uint256 import Uint256 - -__all__ = ["MuxedAccount"] - - +from .muxed_account_med25519 import MuxedAccountMed25519 +__all__ = ['MuxedAccount'] class MuxedAccount: """ XDR Source Code:: @@ -29,7 +29,6 @@ class MuxedAccount: } med25519; }; """ - def __init__( self, type: CryptoKeyType, @@ -39,7 +38,6 @@ def __init__( self.type = type self.ed25519 = ed25519 self.med25519 = med25519 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == CryptoKeyType.KEY_TYPE_ED25519: @@ -52,7 +50,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("med25519 should not be None.") self.med25519.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> MuxedAccount: type = CryptoKeyType.unpack(unpacker) @@ -63,7 +60,6 @@ def unpack(cls, unpacker: Unpacker) -> MuxedAccount: med25519 = MuxedAccountMed25519.unpack(unpacker) return cls(type=type, med25519=med25519) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -82,28 +78,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> MuxedAccount: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.ed25519, - self.med25519, - ) - ) - + return hash((self.type, self.ed25519, self.med25519,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.ed25519 == other.ed25519 - and self.med25519 == other.med25519 - ) - + return self.type== other.type and self.ed25519== other.ed25519 and self.med25519== other.med25519 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"ed25519={self.ed25519}") if self.ed25519 is not None else None - out.append(f"med25519={self.med25519}") if self.med25519 is not None else None + out.append(f'type={self.type}') + out.append(f'ed25519={self.ed25519}') if self.ed25519 is not None else None + out.append(f'med25519={self.med25519}') if self.med25519 is not None else None return f"" diff --git a/stellar_sdk/xdr/muxed_account_med25519.py b/stellar_sdk/xdr/muxed_account_med25519.py index f3cb085b..cd7b2c53 100644 --- a/stellar_sdk/xdr/muxed_account_med25519.py +++ b/stellar_sdk/xdr/muxed_account_med25519.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint64 import Uint64 from .uint256 import Uint256 - -__all__ = ["MuxedAccountMed25519"] - - +__all__ = ['MuxedAccountMed25519'] class MuxedAccountMed25519: """ XDR Source Code:: @@ -22,7 +22,6 @@ class MuxedAccountMed25519: uint256 ed25519; } """ - def __init__( self, id: Uint64, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.id = id self.ed25519 = ed25519 - def pack(self, packer: Packer) -> None: self.id.pack(packer) self.ed25519.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> MuxedAccountMed25519: id = Uint64.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> MuxedAccountMed25519: id=id, ed25519=ed25519, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> MuxedAccountMed25519: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.id, - self.ed25519, - ) - ) - + return hash((self.id, self.ed25519,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.id == other.id and self.ed25519 == other.ed25519 - + return self.id== other.id and self.ed25519== other.ed25519 def __str__(self): out = [ - f"id={self.id}", - f"ed25519={self.ed25519}", + f'id={self.id}', + f'ed25519={self.ed25519}', ] return f"" diff --git a/stellar_sdk/xdr/node_id.py b/stellar_sdk/xdr/node_id.py index 65c60eb1..096ecf4d 100644 --- a/stellar_sdk/xdr/node_id.py +++ b/stellar_sdk/xdr/node_id.py @@ -3,32 +3,28 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .public_key import PublicKey - -__all__ = ["NodeID"] - - +__all__ = ['NodeID'] class NodeID: """ XDR Source Code:: typedef PublicKey NodeID; """ - def __init__(self, node_id: PublicKey) -> None: self.node_id = node_id - def pack(self, packer: Packer) -> None: self.node_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> NodeID: node_id = PublicKey.unpack(unpacker) return cls(node_id) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +43,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> NodeID: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.node_id) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/offer_entry.py b/stellar_sdk/xdr/offer_entry.py index 96808d15..a20b5082 100644 --- a/stellar_sdk/xdr/offer_entry.py +++ b/stellar_sdk/xdr/offer_entry.py @@ -3,19 +3,21 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID +from .int64 import Int64 +from .asset import Asset from .asset import Asset from .int64 import Int64 -from .offer_entry_ext import OfferEntryExt from .price import Price from .uint32 import Uint32 - -__all__ = ["OfferEntry"] - - +from .offer_entry_ext import OfferEntryExt +__all__ = ['OfferEntry'] class OfferEntry: """ XDR Source Code:: @@ -45,7 +47,6 @@ class OfferEntry: ext; }; """ - def __init__( self, seller_id: AccountID, @@ -65,7 +66,6 @@ def __init__( self.price = price self.flags = flags self.ext = ext - def pack(self, packer: Packer) -> None: self.seller_id.pack(packer) self.offer_id.pack(packer) @@ -75,7 +75,6 @@ def pack(self, packer: Packer) -> None: self.price.pack(packer) self.flags.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> OfferEntry: seller_id = AccountID.unpack(unpacker) @@ -96,7 +95,6 @@ def unpack(cls, unpacker: Unpacker) -> OfferEntry: flags=flags, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -115,44 +113,21 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> OfferEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.seller_id, - self.offer_id, - self.selling, - self.buying, - self.amount, - self.price, - self.flags, - self.ext, - ) - ) - + return hash((self.seller_id, self.offer_id, self.selling, self.buying, self.amount, self.price, self.flags, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.seller_id == other.seller_id - and self.offer_id == other.offer_id - and self.selling == other.selling - and self.buying == other.buying - and self.amount == other.amount - and self.price == other.price - and self.flags == other.flags - and self.ext == other.ext - ) - + return self.seller_id== other.seller_id and self.offer_id== other.offer_id and self.selling== other.selling and self.buying== other.buying and self.amount== other.amount and self.price== other.price and self.flags== other.flags and self.ext== other.ext def __str__(self): out = [ - f"seller_id={self.seller_id}", - f"offer_id={self.offer_id}", - f"selling={self.selling}", - f"buying={self.buying}", - f"amount={self.amount}", - f"price={self.price}", - f"flags={self.flags}", - f"ext={self.ext}", + f'seller_id={self.seller_id}', + f'offer_id={self.offer_id}', + f'selling={self.selling}', + f'buying={self.buying}', + f'amount={self.amount}', + f'price={self.price}', + f'flags={self.flags}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/offer_entry_ext.py b/stellar_sdk/xdr/offer_entry_ext.py index 985d02d9..631debcd 100644 --- a/stellar_sdk/xdr/offer_entry_ext.py +++ b/stellar_sdk/xdr/offer_entry_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["OfferEntryExt"] - - +__all__ = ['OfferEntryExt'] class OfferEntryExt: """ XDR Source Code:: @@ -21,25 +20,21 @@ class OfferEntryExt: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> OfferEntryExt: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> OfferEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/offer_entry_flags.py b/stellar_sdk/xdr/offer_entry_flags.py index 1fcc100d..a0894d37 100644 --- a/stellar_sdk/xdr/offer_entry_flags.py +++ b/stellar_sdk/xdr/offer_entry_flags.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["OfferEntryFlags"] - - +__all__ = ['OfferEntryFlags'] class OfferEntryFlags(IntEnum): """ XDR Source Code:: @@ -21,9 +21,7 @@ class OfferEntryFlags(IntEnum): PASSIVE_FLAG = 1 }; """ - PASSIVE_FLAG = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> OfferEntryFlags: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/operation.py b/stellar_sdk/xdr/operation.py index f6331ea7..50377e70 100644 --- a/stellar_sdk/xdr/operation.py +++ b/stellar_sdk/xdr/operation.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .muxed_account import MuxedAccount from .operation_body import OperationBody - -__all__ = ["Operation"] - - +__all__ = ['Operation'] class Operation: """ XDR Source Code:: @@ -84,7 +83,6 @@ class Operation: body; }; """ - def __init__( self, source_account: Optional[MuxedAccount], @@ -92,7 +90,6 @@ def __init__( ) -> None: self.source_account = source_account self.body = body - def pack(self, packer: Packer) -> None: if self.source_account is None: packer.pack_uint(0) @@ -100,18 +97,14 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(1) self.source_account.pack(packer) self.body.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Operation: - source_account = ( - MuxedAccount.unpack(unpacker) if unpacker.unpack_uint() else None - ) + source_account = MuxedAccount.unpack(unpacker) if unpacker.unpack_uint() else None body = OperationBody.unpack(unpacker) return cls( source_account=source_account, body=body, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -130,23 +123,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Operation: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.source_account, - self.body, - ) - ) - + return hash((self.source_account, self.body,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.source_account == other.source_account and self.body == other.body - + return self.source_account== other.source_account and self.body== other.body def __str__(self): out = [ - f"source_account={self.source_account}", - f"body={self.body}", + f'source_account={self.source_account}', + f'body={self.body}', ] return f"" diff --git a/stellar_sdk/xdr/operation_body.py b/stellar_sdk/xdr/operation_body.py index e590a0f7..911879bf 100644 --- a/stellar_sdk/xdr/operation_body.py +++ b/stellar_sdk/xdr/operation_body.py @@ -3,39 +3,39 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .operation_type import OperationType +from .create_account_op import CreateAccountOp +from .payment_op import PaymentOp +from .path_payment_strict_receive_op import PathPaymentStrictReceiveOp +from .manage_sell_offer_op import ManageSellOfferOp +from .create_passive_sell_offer_op import CreatePassiveSellOfferOp +from .set_options_op import SetOptionsOp +from .change_trust_op import ChangeTrustOp from .allow_trust_op import AllowTrustOp -from .begin_sponsoring_future_reserves_op import BeginSponsoringFutureReservesOp -from .bump_footprint_expiration_op import BumpFootprintExpirationOp +from .muxed_account import MuxedAccount +from .manage_data_op import ManageDataOp from .bump_sequence_op import BumpSequenceOp -from .change_trust_op import ChangeTrustOp +from .manage_buy_offer_op import ManageBuyOfferOp +from .path_payment_strict_send_op import PathPaymentStrictSendOp +from .create_claimable_balance_op import CreateClaimableBalanceOp from .claim_claimable_balance_op import ClaimClaimableBalanceOp -from .clawback_claimable_balance_op import ClawbackClaimableBalanceOp +from .begin_sponsoring_future_reserves_op import BeginSponsoringFutureReservesOp +from .revoke_sponsorship_op import RevokeSponsorshipOp from .clawback_op import ClawbackOp -from .create_account_op import CreateAccountOp -from .create_claimable_balance_op import CreateClaimableBalanceOp -from .create_passive_sell_offer_op import CreatePassiveSellOfferOp -from .invoke_host_function_op import InvokeHostFunctionOp +from .clawback_claimable_balance_op import ClawbackClaimableBalanceOp +from .set_trust_line_flags_op import SetTrustLineFlagsOp from .liquidity_pool_deposit_op import LiquidityPoolDepositOp from .liquidity_pool_withdraw_op import LiquidityPoolWithdrawOp -from .manage_buy_offer_op import ManageBuyOfferOp -from .manage_data_op import ManageDataOp -from .manage_sell_offer_op import ManageSellOfferOp -from .muxed_account import MuxedAccount -from .operation_type import OperationType -from .path_payment_strict_receive_op import PathPaymentStrictReceiveOp -from .path_payment_strict_send_op import PathPaymentStrictSendOp -from .payment_op import PaymentOp +from .invoke_host_function_op import InvokeHostFunctionOp +from .bump_footprint_expiration_op import BumpFootprintExpirationOp from .restore_footprint_op import RestoreFootprintOp -from .revoke_sponsorship_op import RevokeSponsorshipOp -from .set_options_op import SetOptionsOp -from .set_trust_line_flags_op import SetTrustLineFlagsOp - -__all__ = ["OperationBody"] - - +__all__ = ['OperationBody'] class OperationBody: """ XDR Source Code:: @@ -98,7 +98,6 @@ class OperationBody: RestoreFootprintOp restoreFootprintOp; } """ - def __init__( self, type: OperationType, @@ -154,7 +153,6 @@ def __init__( self.invoke_host_function_op = invoke_host_function_op self.bump_footprint_expiration_op = bump_footprint_expiration_op self.restore_footprint_op = restore_footprint_op - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == OperationType.CREATE_ACCOUNT: @@ -236,9 +234,7 @@ def pack(self, packer: Packer) -> None: return if self.type == OperationType.BEGIN_SPONSORING_FUTURE_RESERVES: if self.begin_sponsoring_future_reserves_op is None: - raise ValueError( - "begin_sponsoring_future_reserves_op should not be None." - ) + raise ValueError("begin_sponsoring_future_reserves_op should not be None.") self.begin_sponsoring_future_reserves_op.pack(packer) return if self.type == OperationType.END_SPONSORING_FUTURE_RESERVES: @@ -288,7 +284,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("restore_footprint_op should not be None.") self.restore_footprint_op.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> OperationBody: type = OperationType.unpack(unpacker) @@ -300,17 +295,13 @@ def unpack(cls, unpacker: Unpacker) -> OperationBody: return cls(type=type, payment_op=payment_op) if type == OperationType.PATH_PAYMENT_STRICT_RECEIVE: path_payment_strict_receive_op = PathPaymentStrictReceiveOp.unpack(unpacker) - return cls( - type=type, path_payment_strict_receive_op=path_payment_strict_receive_op - ) + return cls(type=type, path_payment_strict_receive_op=path_payment_strict_receive_op) if type == OperationType.MANAGE_SELL_OFFER: manage_sell_offer_op = ManageSellOfferOp.unpack(unpacker) return cls(type=type, manage_sell_offer_op=manage_sell_offer_op) if type == OperationType.CREATE_PASSIVE_SELL_OFFER: create_passive_sell_offer_op = CreatePassiveSellOfferOp.unpack(unpacker) - return cls( - type=type, create_passive_sell_offer_op=create_passive_sell_offer_op - ) + return cls(type=type, create_passive_sell_offer_op=create_passive_sell_offer_op) if type == OperationType.SET_OPTIONS: set_options_op = SetOptionsOp.unpack(unpacker) return cls(type=type, set_options_op=set_options_op) @@ -336,25 +327,16 @@ def unpack(cls, unpacker: Unpacker) -> OperationBody: return cls(type=type, manage_buy_offer_op=manage_buy_offer_op) if type == OperationType.PATH_PAYMENT_STRICT_SEND: path_payment_strict_send_op = PathPaymentStrictSendOp.unpack(unpacker) - return cls( - type=type, path_payment_strict_send_op=path_payment_strict_send_op - ) + return cls(type=type, path_payment_strict_send_op=path_payment_strict_send_op) if type == OperationType.CREATE_CLAIMABLE_BALANCE: create_claimable_balance_op = CreateClaimableBalanceOp.unpack(unpacker) - return cls( - type=type, create_claimable_balance_op=create_claimable_balance_op - ) + return cls(type=type, create_claimable_balance_op=create_claimable_balance_op) if type == OperationType.CLAIM_CLAIMABLE_BALANCE: claim_claimable_balance_op = ClaimClaimableBalanceOp.unpack(unpacker) return cls(type=type, claim_claimable_balance_op=claim_claimable_balance_op) if type == OperationType.BEGIN_SPONSORING_FUTURE_RESERVES: - begin_sponsoring_future_reserves_op = ( - BeginSponsoringFutureReservesOp.unpack(unpacker) - ) - return cls( - type=type, - begin_sponsoring_future_reserves_op=begin_sponsoring_future_reserves_op, - ) + begin_sponsoring_future_reserves_op = BeginSponsoringFutureReservesOp.unpack(unpacker) + return cls(type=type, begin_sponsoring_future_reserves_op=begin_sponsoring_future_reserves_op) if type == OperationType.END_SPONSORING_FUTURE_RESERVES: return cls(type=type) if type == OperationType.REVOKE_SPONSORSHIP: @@ -365,9 +347,7 @@ def unpack(cls, unpacker: Unpacker) -> OperationBody: return cls(type=type, clawback_op=clawback_op) if type == OperationType.CLAWBACK_CLAIMABLE_BALANCE: clawback_claimable_balance_op = ClawbackClaimableBalanceOp.unpack(unpacker) - return cls( - type=type, clawback_claimable_balance_op=clawback_claimable_balance_op - ) + return cls(type=type, clawback_claimable_balance_op=clawback_claimable_balance_op) if type == OperationType.SET_TRUST_LINE_FLAGS: set_trust_line_flags_op = SetTrustLineFlagsOp.unpack(unpacker) return cls(type=type, set_trust_line_flags_op=set_trust_line_flags_op) @@ -382,14 +362,11 @@ def unpack(cls, unpacker: Unpacker) -> OperationBody: return cls(type=type, invoke_host_function_op=invoke_host_function_op) if type == OperationType.BUMP_FOOTPRINT_EXPIRATION: bump_footprint_expiration_op = BumpFootprintExpirationOp.unpack(unpacker) - return cls( - type=type, bump_footprint_expiration_op=bump_footprint_expiration_op - ) + return cls(type=type, bump_footprint_expiration_op=bump_footprint_expiration_op) if type == OperationType.RESTORE_FOOTPRINT: restore_footprint_op = RestoreFootprintOp.unpack(unpacker) return cls(type=type, restore_footprint_op=restore_footprint_op) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -408,150 +385,38 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> OperationBody: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.create_account_op, - self.payment_op, - self.path_payment_strict_receive_op, - self.manage_sell_offer_op, - self.create_passive_sell_offer_op, - self.set_options_op, - self.change_trust_op, - self.allow_trust_op, - self.destination, - self.manage_data_op, - self.bump_sequence_op, - self.manage_buy_offer_op, - self.path_payment_strict_send_op, - self.create_claimable_balance_op, - self.claim_claimable_balance_op, - self.begin_sponsoring_future_reserves_op, - self.revoke_sponsorship_op, - self.clawback_op, - self.clawback_claimable_balance_op, - self.set_trust_line_flags_op, - self.liquidity_pool_deposit_op, - self.liquidity_pool_withdraw_op, - self.invoke_host_function_op, - self.bump_footprint_expiration_op, - self.restore_footprint_op, - ) - ) - + return hash((self.type, self.create_account_op, self.payment_op, self.path_payment_strict_receive_op, self.manage_sell_offer_op, self.create_passive_sell_offer_op, self.set_options_op, self.change_trust_op, self.allow_trust_op, self.destination, self.manage_data_op, self.bump_sequence_op, self.manage_buy_offer_op, self.path_payment_strict_send_op, self.create_claimable_balance_op, self.claim_claimable_balance_op, self.begin_sponsoring_future_reserves_op, self.revoke_sponsorship_op, self.clawback_op, self.clawback_claimable_balance_op, self.set_trust_line_flags_op, self.liquidity_pool_deposit_op, self.liquidity_pool_withdraw_op, self.invoke_host_function_op, self.bump_footprint_expiration_op, self.restore_footprint_op,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.create_account_op == other.create_account_op - and self.payment_op == other.payment_op - and self.path_payment_strict_receive_op - == other.path_payment_strict_receive_op - and self.manage_sell_offer_op == other.manage_sell_offer_op - and self.create_passive_sell_offer_op == other.create_passive_sell_offer_op - and self.set_options_op == other.set_options_op - and self.change_trust_op == other.change_trust_op - and self.allow_trust_op == other.allow_trust_op - and self.destination == other.destination - and self.manage_data_op == other.manage_data_op - and self.bump_sequence_op == other.bump_sequence_op - and self.manage_buy_offer_op == other.manage_buy_offer_op - and self.path_payment_strict_send_op == other.path_payment_strict_send_op - and self.create_claimable_balance_op == other.create_claimable_balance_op - and self.claim_claimable_balance_op == other.claim_claimable_balance_op - and self.begin_sponsoring_future_reserves_op - == other.begin_sponsoring_future_reserves_op - and self.revoke_sponsorship_op == other.revoke_sponsorship_op - and self.clawback_op == other.clawback_op - and self.clawback_claimable_balance_op - == other.clawback_claimable_balance_op - and self.set_trust_line_flags_op == other.set_trust_line_flags_op - and self.liquidity_pool_deposit_op == other.liquidity_pool_deposit_op - and self.liquidity_pool_withdraw_op == other.liquidity_pool_withdraw_op - and self.invoke_host_function_op == other.invoke_host_function_op - and self.bump_footprint_expiration_op == other.bump_footprint_expiration_op - and self.restore_footprint_op == other.restore_footprint_op - ) - + return self.type== other.type and self.create_account_op== other.create_account_op and self.payment_op== other.payment_op and self.path_payment_strict_receive_op== other.path_payment_strict_receive_op and self.manage_sell_offer_op== other.manage_sell_offer_op and self.create_passive_sell_offer_op== other.create_passive_sell_offer_op and self.set_options_op== other.set_options_op and self.change_trust_op== other.change_trust_op and self.allow_trust_op== other.allow_trust_op and self.destination== other.destination and self.manage_data_op== other.manage_data_op and self.bump_sequence_op== other.bump_sequence_op and self.manage_buy_offer_op== other.manage_buy_offer_op and self.path_payment_strict_send_op== other.path_payment_strict_send_op and self.create_claimable_balance_op== other.create_claimable_balance_op and self.claim_claimable_balance_op== other.claim_claimable_balance_op and self.begin_sponsoring_future_reserves_op== other.begin_sponsoring_future_reserves_op and self.revoke_sponsorship_op== other.revoke_sponsorship_op and self.clawback_op== other.clawback_op and self.clawback_claimable_balance_op== other.clawback_claimable_balance_op and self.set_trust_line_flags_op== other.set_trust_line_flags_op and self.liquidity_pool_deposit_op== other.liquidity_pool_deposit_op and self.liquidity_pool_withdraw_op== other.liquidity_pool_withdraw_op and self.invoke_host_function_op== other.invoke_host_function_op and self.bump_footprint_expiration_op== other.bump_footprint_expiration_op and self.restore_footprint_op== other.restore_footprint_op def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"create_account_op={self.create_account_op}" - ) if self.create_account_op is not None else None - out.append( - f"payment_op={self.payment_op}" - ) if self.payment_op is not None else None - out.append( - f"path_payment_strict_receive_op={self.path_payment_strict_receive_op}" - ) if self.path_payment_strict_receive_op is not None else None - out.append( - f"manage_sell_offer_op={self.manage_sell_offer_op}" - ) if self.manage_sell_offer_op is not None else None - out.append( - f"create_passive_sell_offer_op={self.create_passive_sell_offer_op}" - ) if self.create_passive_sell_offer_op is not None else None - out.append( - f"set_options_op={self.set_options_op}" - ) if self.set_options_op is not None else None - out.append( - f"change_trust_op={self.change_trust_op}" - ) if self.change_trust_op is not None else None - out.append( - f"allow_trust_op={self.allow_trust_op}" - ) if self.allow_trust_op is not None else None - out.append( - f"destination={self.destination}" - ) if self.destination is not None else None - out.append( - f"manage_data_op={self.manage_data_op}" - ) if self.manage_data_op is not None else None - out.append( - f"bump_sequence_op={self.bump_sequence_op}" - ) if self.bump_sequence_op is not None else None - out.append( - f"manage_buy_offer_op={self.manage_buy_offer_op}" - ) if self.manage_buy_offer_op is not None else None - out.append( - f"path_payment_strict_send_op={self.path_payment_strict_send_op}" - ) if self.path_payment_strict_send_op is not None else None - out.append( - f"create_claimable_balance_op={self.create_claimable_balance_op}" - ) if self.create_claimable_balance_op is not None else None - out.append( - f"claim_claimable_balance_op={self.claim_claimable_balance_op}" - ) if self.claim_claimable_balance_op is not None else None - out.append( - f"begin_sponsoring_future_reserves_op={self.begin_sponsoring_future_reserves_op}" - ) if self.begin_sponsoring_future_reserves_op is not None else None - out.append( - f"revoke_sponsorship_op={self.revoke_sponsorship_op}" - ) if self.revoke_sponsorship_op is not None else None - out.append( - f"clawback_op={self.clawback_op}" - ) if self.clawback_op is not None else None - out.append( - f"clawback_claimable_balance_op={self.clawback_claimable_balance_op}" - ) if self.clawback_claimable_balance_op is not None else None - out.append( - f"set_trust_line_flags_op={self.set_trust_line_flags_op}" - ) if self.set_trust_line_flags_op is not None else None - out.append( - f"liquidity_pool_deposit_op={self.liquidity_pool_deposit_op}" - ) if self.liquidity_pool_deposit_op is not None else None - out.append( - f"liquidity_pool_withdraw_op={self.liquidity_pool_withdraw_op}" - ) if self.liquidity_pool_withdraw_op is not None else None - out.append( - f"invoke_host_function_op={self.invoke_host_function_op}" - ) if self.invoke_host_function_op is not None else None - out.append( - f"bump_footprint_expiration_op={self.bump_footprint_expiration_op}" - ) if self.bump_footprint_expiration_op is not None else None - out.append( - f"restore_footprint_op={self.restore_footprint_op}" - ) if self.restore_footprint_op is not None else None + out.append(f'type={self.type}') + out.append(f'create_account_op={self.create_account_op}') if self.create_account_op is not None else None + out.append(f'payment_op={self.payment_op}') if self.payment_op is not None else None + out.append(f'path_payment_strict_receive_op={self.path_payment_strict_receive_op}') if self.path_payment_strict_receive_op is not None else None + out.append(f'manage_sell_offer_op={self.manage_sell_offer_op}') if self.manage_sell_offer_op is not None else None + out.append(f'create_passive_sell_offer_op={self.create_passive_sell_offer_op}') if self.create_passive_sell_offer_op is not None else None + out.append(f'set_options_op={self.set_options_op}') if self.set_options_op is not None else None + out.append(f'change_trust_op={self.change_trust_op}') if self.change_trust_op is not None else None + out.append(f'allow_trust_op={self.allow_trust_op}') if self.allow_trust_op is not None else None + out.append(f'destination={self.destination}') if self.destination is not None else None + out.append(f'manage_data_op={self.manage_data_op}') if self.manage_data_op is not None else None + out.append(f'bump_sequence_op={self.bump_sequence_op}') if self.bump_sequence_op is not None else None + out.append(f'manage_buy_offer_op={self.manage_buy_offer_op}') if self.manage_buy_offer_op is not None else None + out.append(f'path_payment_strict_send_op={self.path_payment_strict_send_op}') if self.path_payment_strict_send_op is not None else None + out.append(f'create_claimable_balance_op={self.create_claimable_balance_op}') if self.create_claimable_balance_op is not None else None + out.append(f'claim_claimable_balance_op={self.claim_claimable_balance_op}') if self.claim_claimable_balance_op is not None else None + out.append(f'begin_sponsoring_future_reserves_op={self.begin_sponsoring_future_reserves_op}') if self.begin_sponsoring_future_reserves_op is not None else None + out.append(f'revoke_sponsorship_op={self.revoke_sponsorship_op}') if self.revoke_sponsorship_op is not None else None + out.append(f'clawback_op={self.clawback_op}') if self.clawback_op is not None else None + out.append(f'clawback_claimable_balance_op={self.clawback_claimable_balance_op}') if self.clawback_claimable_balance_op is not None else None + out.append(f'set_trust_line_flags_op={self.set_trust_line_flags_op}') if self.set_trust_line_flags_op is not None else None + out.append(f'liquidity_pool_deposit_op={self.liquidity_pool_deposit_op}') if self.liquidity_pool_deposit_op is not None else None + out.append(f'liquidity_pool_withdraw_op={self.liquidity_pool_withdraw_op}') if self.liquidity_pool_withdraw_op is not None else None + out.append(f'invoke_host_function_op={self.invoke_host_function_op}') if self.invoke_host_function_op is not None else None + out.append(f'bump_footprint_expiration_op={self.bump_footprint_expiration_op}') if self.bump_footprint_expiration_op is not None else None + out.append(f'restore_footprint_op={self.restore_footprint_op}') if self.restore_footprint_op is not None else None return f"" diff --git a/stellar_sdk/xdr/operation_meta.py b/stellar_sdk/xdr/operation_meta.py index eb207451..15e0c02f 100644 --- a/stellar_sdk/xdr/operation_meta.py +++ b/stellar_sdk/xdr/operation_meta.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .ledger_entry_changes import LedgerEntryChanges - -__all__ = ["OperationMeta"] - - +__all__ = ['OperationMeta'] class OperationMeta: """ XDR Source Code:: @@ -20,23 +20,19 @@ class OperationMeta: LedgerEntryChanges changes; }; """ - def __init__( self, changes: LedgerEntryChanges, ) -> None: self.changes = changes - def pack(self, packer: Packer) -> None: self.changes.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> OperationMeta: changes = LedgerEntryChanges.unpack(unpacker) return cls( changes=changes, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> OperationMeta: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.changes,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.changes == other.changes - + return self.changes== other.changes def __str__(self): out = [ - f"changes={self.changes}", + f'changes={self.changes}', ] return f"" diff --git a/stellar_sdk/xdr/operation_result.py b/stellar_sdk/xdr/operation_result.py index b475d85c..aaa357f8 100644 --- a/stellar_sdk/xdr/operation_result.py +++ b/stellar_sdk/xdr/operation_result.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .operation_result_code import OperationResultCode from .operation_result_tr import OperationResultTr - -__all__ = ["OperationResult"] - - +__all__ = ['OperationResult'] class OperationResult: """ XDR Source Code:: @@ -86,7 +86,6 @@ class OperationResult: void; }; """ - def __init__( self, code: OperationResultCode, @@ -94,7 +93,6 @@ def __init__( ) -> None: self.code = code self.tr = tr - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == OperationResultCode.opINNER: @@ -114,7 +112,6 @@ def pack(self, packer: Packer) -> None: return if self.code == OperationResultCode.opTOO_MANY_SPONSORING: return - @classmethod def unpack(cls, unpacker: Unpacker) -> OperationResult: code = OperationResultCode.unpack(unpacker) @@ -134,7 +131,6 @@ def unpack(cls, unpacker: Unpacker) -> OperationResult: if code == OperationResultCode.opTOO_MANY_SPONSORING: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -153,22 +149,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> OperationResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.tr, - ) - ) - + return hash((self.code, self.tr,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code and self.tr == other.tr - + return self.code== other.code and self.tr== other.tr def __str__(self): out = [] - out.append(f"code={self.code}") - out.append(f"tr={self.tr}") if self.tr is not None else None + out.append(f'code={self.code}') + out.append(f'tr={self.tr}') if self.tr is not None else None return f"" diff --git a/stellar_sdk/xdr/operation_result_code.py b/stellar_sdk/xdr/operation_result_code.py index a21c79ff..c52de8e6 100644 --- a/stellar_sdk/xdr/operation_result_code.py +++ b/stellar_sdk/xdr/operation_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["OperationResultCode"] - - +__all__ = ['OperationResultCode'] class OperationResultCode(IntEnum): """ XDR Source Code:: @@ -26,7 +26,6 @@ class OperationResultCode(IntEnum): opTOO_MANY_SPONSORING = -6 // account is sponsoring too many entries }; """ - opINNER = 0 opBAD_AUTH = -1 opNO_ACCOUNT = -2 @@ -34,7 +33,6 @@ class OperationResultCode(IntEnum): opTOO_MANY_SUBENTRIES = -4 opEXCEEDED_WORK_LIMIT = -5 opTOO_MANY_SPONSORING = -6 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -42,7 +40,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> OperationResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/operation_result_tr.py b/stellar_sdk/xdr/operation_result_tr.py index 351d5c23..b3db5917 100644 --- a/stellar_sdk/xdr/operation_result_tr.py +++ b/stellar_sdk/xdr/operation_result_tr.py @@ -3,40 +3,41 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .account_merge_result import AccountMergeResult +from .operation_type import OperationType +from .create_account_result import CreateAccountResult +from .payment_result import PaymentResult +from .path_payment_strict_receive_result import PathPaymentStrictReceiveResult +from .manage_sell_offer_result import ManageSellOfferResult +from .manage_sell_offer_result import ManageSellOfferResult +from .set_options_result import SetOptionsResult +from .change_trust_result import ChangeTrustResult from .allow_trust_result import AllowTrustResult -from .begin_sponsoring_future_reserves_result import BeginSponsoringFutureReservesResult -from .bump_footprint_expiration_result import BumpFootprintExpirationResult +from .account_merge_result import AccountMergeResult +from .inflation_result import InflationResult +from .manage_data_result import ManageDataResult from .bump_sequence_result import BumpSequenceResult -from .change_trust_result import ChangeTrustResult -from .claim_claimable_balance_result import ClaimClaimableBalanceResult -from .clawback_claimable_balance_result import ClawbackClaimableBalanceResult -from .clawback_result import ClawbackResult -from .create_account_result import CreateAccountResult +from .manage_buy_offer_result import ManageBuyOfferResult +from .path_payment_strict_send_result import PathPaymentStrictSendResult from .create_claimable_balance_result import CreateClaimableBalanceResult +from .claim_claimable_balance_result import ClaimClaimableBalanceResult +from .begin_sponsoring_future_reserves_result import BeginSponsoringFutureReservesResult from .end_sponsoring_future_reserves_result import EndSponsoringFutureReservesResult -from .inflation_result import InflationResult -from .invoke_host_function_result import InvokeHostFunctionResult +from .revoke_sponsorship_result import RevokeSponsorshipResult +from .clawback_result import ClawbackResult +from .clawback_claimable_balance_result import ClawbackClaimableBalanceResult +from .set_trust_line_flags_result import SetTrustLineFlagsResult from .liquidity_pool_deposit_result import LiquidityPoolDepositResult from .liquidity_pool_withdraw_result import LiquidityPoolWithdrawResult -from .manage_buy_offer_result import ManageBuyOfferResult -from .manage_data_result import ManageDataResult -from .manage_sell_offer_result import ManageSellOfferResult -from .operation_type import OperationType -from .path_payment_strict_receive_result import PathPaymentStrictReceiveResult -from .path_payment_strict_send_result import PathPaymentStrictSendResult -from .payment_result import PaymentResult +from .invoke_host_function_result import InvokeHostFunctionResult +from .bump_footprint_expiration_result import BumpFootprintExpirationResult from .restore_footprint_result import RestoreFootprintResult -from .revoke_sponsorship_result import RevokeSponsorshipResult -from .set_options_result import SetOptionsResult -from .set_trust_line_flags_result import SetTrustLineFlagsResult - -__all__ = ["OperationResultTr"] - - +__all__ = ['OperationResultTr'] class OperationResultTr: """ XDR Source Code:: @@ -99,7 +100,6 @@ class OperationResultTr: RestoreFootprintResult restoreFootprintResult; } """ - def __init__( self, type: OperationType, @@ -148,12 +148,8 @@ def __init__( self.path_payment_strict_send_result = path_payment_strict_send_result self.create_claimable_balance_result = create_claimable_balance_result self.claim_claimable_balance_result = claim_claimable_balance_result - self.begin_sponsoring_future_reserves_result = ( - begin_sponsoring_future_reserves_result - ) - self.end_sponsoring_future_reserves_result = ( - end_sponsoring_future_reserves_result - ) + self.begin_sponsoring_future_reserves_result = begin_sponsoring_future_reserves_result + self.end_sponsoring_future_reserves_result = end_sponsoring_future_reserves_result self.revoke_sponsorship_result = revoke_sponsorship_result self.clawback_result = clawback_result self.clawback_claimable_balance_result = clawback_claimable_balance_result @@ -163,7 +159,6 @@ def __init__( self.invoke_host_function_result = invoke_host_function_result self.bump_footprint_expiration_result = bump_footprint_expiration_result self.restore_footprint_result = restore_footprint_result - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == OperationType.CREATE_ACCOUNT: @@ -178,9 +173,7 @@ def pack(self, packer: Packer) -> None: return if self.type == OperationType.PATH_PAYMENT_STRICT_RECEIVE: if self.path_payment_strict_receive_result is None: - raise ValueError( - "path_payment_strict_receive_result should not be None." - ) + raise ValueError("path_payment_strict_receive_result should not be None.") self.path_payment_strict_receive_result.pack(packer) return if self.type == OperationType.MANAGE_SELL_OFFER: @@ -250,16 +243,12 @@ def pack(self, packer: Packer) -> None: return if self.type == OperationType.BEGIN_SPONSORING_FUTURE_RESERVES: if self.begin_sponsoring_future_reserves_result is None: - raise ValueError( - "begin_sponsoring_future_reserves_result should not be None." - ) + raise ValueError("begin_sponsoring_future_reserves_result should not be None.") self.begin_sponsoring_future_reserves_result.pack(packer) return if self.type == OperationType.END_SPONSORING_FUTURE_RESERVES: if self.end_sponsoring_future_reserves_result is None: - raise ValueError( - "end_sponsoring_future_reserves_result should not be None." - ) + raise ValueError("end_sponsoring_future_reserves_result should not be None.") self.end_sponsoring_future_reserves_result.pack(packer) return if self.type == OperationType.REVOKE_SPONSORSHIP: @@ -274,9 +263,7 @@ def pack(self, packer: Packer) -> None: return if self.type == OperationType.CLAWBACK_CLAIMABLE_BALANCE: if self.clawback_claimable_balance_result is None: - raise ValueError( - "clawback_claimable_balance_result should not be None." - ) + raise ValueError("clawback_claimable_balance_result should not be None.") self.clawback_claimable_balance_result.pack(packer) return if self.type == OperationType.SET_TRUST_LINE_FLAGS: @@ -309,7 +296,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("restore_footprint_result should not be None.") self.restore_footprint_result.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> OperationResultTr: type = OperationType.unpack(unpacker) @@ -320,22 +306,14 @@ def unpack(cls, unpacker: Unpacker) -> OperationResultTr: payment_result = PaymentResult.unpack(unpacker) return cls(type=type, payment_result=payment_result) if type == OperationType.PATH_PAYMENT_STRICT_RECEIVE: - path_payment_strict_receive_result = PathPaymentStrictReceiveResult.unpack( - unpacker - ) - return cls( - type=type, - path_payment_strict_receive_result=path_payment_strict_receive_result, - ) + path_payment_strict_receive_result = PathPaymentStrictReceiveResult.unpack(unpacker) + return cls(type=type, path_payment_strict_receive_result=path_payment_strict_receive_result) if type == OperationType.MANAGE_SELL_OFFER: manage_sell_offer_result = ManageSellOfferResult.unpack(unpacker) return cls(type=type, manage_sell_offer_result=manage_sell_offer_result) if type == OperationType.CREATE_PASSIVE_SELL_OFFER: create_passive_sell_offer_result = ManageSellOfferResult.unpack(unpacker) - return cls( - type=type, - create_passive_sell_offer_result=create_passive_sell_offer_result, - ) + return cls(type=type, create_passive_sell_offer_result=create_passive_sell_offer_result) if type == OperationType.SET_OPTIONS: set_options_result = SetOptionsResult.unpack(unpacker) return cls(type=type, set_options_result=set_options_result) @@ -361,44 +339,20 @@ def unpack(cls, unpacker: Unpacker) -> OperationResultTr: manage_buy_offer_result = ManageBuyOfferResult.unpack(unpacker) return cls(type=type, manage_buy_offer_result=manage_buy_offer_result) if type == OperationType.PATH_PAYMENT_STRICT_SEND: - path_payment_strict_send_result = PathPaymentStrictSendResult.unpack( - unpacker - ) - return cls( - type=type, - path_payment_strict_send_result=path_payment_strict_send_result, - ) + path_payment_strict_send_result = PathPaymentStrictSendResult.unpack(unpacker) + return cls(type=type, path_payment_strict_send_result=path_payment_strict_send_result) if type == OperationType.CREATE_CLAIMABLE_BALANCE: - create_claimable_balance_result = CreateClaimableBalanceResult.unpack( - unpacker - ) - return cls( - type=type, - create_claimable_balance_result=create_claimable_balance_result, - ) + create_claimable_balance_result = CreateClaimableBalanceResult.unpack(unpacker) + return cls(type=type, create_claimable_balance_result=create_claimable_balance_result) if type == OperationType.CLAIM_CLAIMABLE_BALANCE: - claim_claimable_balance_result = ClaimClaimableBalanceResult.unpack( - unpacker - ) - return cls( - type=type, claim_claimable_balance_result=claim_claimable_balance_result - ) + claim_claimable_balance_result = ClaimClaimableBalanceResult.unpack(unpacker) + return cls(type=type, claim_claimable_balance_result=claim_claimable_balance_result) if type == OperationType.BEGIN_SPONSORING_FUTURE_RESERVES: - begin_sponsoring_future_reserves_result = ( - BeginSponsoringFutureReservesResult.unpack(unpacker) - ) - return cls( - type=type, - begin_sponsoring_future_reserves_result=begin_sponsoring_future_reserves_result, - ) + begin_sponsoring_future_reserves_result = BeginSponsoringFutureReservesResult.unpack(unpacker) + return cls(type=type, begin_sponsoring_future_reserves_result=begin_sponsoring_future_reserves_result) if type == OperationType.END_SPONSORING_FUTURE_RESERVES: - end_sponsoring_future_reserves_result = ( - EndSponsoringFutureReservesResult.unpack(unpacker) - ) - return cls( - type=type, - end_sponsoring_future_reserves_result=end_sponsoring_future_reserves_result, - ) + end_sponsoring_future_reserves_result = EndSponsoringFutureReservesResult.unpack(unpacker) + return cls(type=type, end_sponsoring_future_reserves_result=end_sponsoring_future_reserves_result) if type == OperationType.REVOKE_SPONSORSHIP: revoke_sponsorship_result = RevokeSponsorshipResult.unpack(unpacker) return cls(type=type, revoke_sponsorship_result=revoke_sponsorship_result) @@ -406,48 +360,27 @@ def unpack(cls, unpacker: Unpacker) -> OperationResultTr: clawback_result = ClawbackResult.unpack(unpacker) return cls(type=type, clawback_result=clawback_result) if type == OperationType.CLAWBACK_CLAIMABLE_BALANCE: - clawback_claimable_balance_result = ClawbackClaimableBalanceResult.unpack( - unpacker - ) - return cls( - type=type, - clawback_claimable_balance_result=clawback_claimable_balance_result, - ) + clawback_claimable_balance_result = ClawbackClaimableBalanceResult.unpack(unpacker) + return cls(type=type, clawback_claimable_balance_result=clawback_claimable_balance_result) if type == OperationType.SET_TRUST_LINE_FLAGS: set_trust_line_flags_result = SetTrustLineFlagsResult.unpack(unpacker) - return cls( - type=type, set_trust_line_flags_result=set_trust_line_flags_result - ) + return cls(type=type, set_trust_line_flags_result=set_trust_line_flags_result) if type == OperationType.LIQUIDITY_POOL_DEPOSIT: liquidity_pool_deposit_result = LiquidityPoolDepositResult.unpack(unpacker) - return cls( - type=type, liquidity_pool_deposit_result=liquidity_pool_deposit_result - ) + return cls(type=type, liquidity_pool_deposit_result=liquidity_pool_deposit_result) if type == OperationType.LIQUIDITY_POOL_WITHDRAW: - liquidity_pool_withdraw_result = LiquidityPoolWithdrawResult.unpack( - unpacker - ) - return cls( - type=type, liquidity_pool_withdraw_result=liquidity_pool_withdraw_result - ) + liquidity_pool_withdraw_result = LiquidityPoolWithdrawResult.unpack(unpacker) + return cls(type=type, liquidity_pool_withdraw_result=liquidity_pool_withdraw_result) if type == OperationType.INVOKE_HOST_FUNCTION: invoke_host_function_result = InvokeHostFunctionResult.unpack(unpacker) - return cls( - type=type, invoke_host_function_result=invoke_host_function_result - ) + return cls(type=type, invoke_host_function_result=invoke_host_function_result) if type == OperationType.BUMP_FOOTPRINT_EXPIRATION: - bump_footprint_expiration_result = BumpFootprintExpirationResult.unpack( - unpacker - ) - return cls( - type=type, - bump_footprint_expiration_result=bump_footprint_expiration_result, - ) + bump_footprint_expiration_result = BumpFootprintExpirationResult.unpack(unpacker) + return cls(type=type, bump_footprint_expiration_result=bump_footprint_expiration_result) if type == OperationType.RESTORE_FOOTPRINT: restore_footprint_result = RestoreFootprintResult.unpack(unpacker) return cls(type=type, restore_footprint_result=restore_footprint_result) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -466,168 +399,40 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> OperationResultTr: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.create_account_result, - self.payment_result, - self.path_payment_strict_receive_result, - self.manage_sell_offer_result, - self.create_passive_sell_offer_result, - self.set_options_result, - self.change_trust_result, - self.allow_trust_result, - self.account_merge_result, - self.inflation_result, - self.manage_data_result, - self.bump_seq_result, - self.manage_buy_offer_result, - self.path_payment_strict_send_result, - self.create_claimable_balance_result, - self.claim_claimable_balance_result, - self.begin_sponsoring_future_reserves_result, - self.end_sponsoring_future_reserves_result, - self.revoke_sponsorship_result, - self.clawback_result, - self.clawback_claimable_balance_result, - self.set_trust_line_flags_result, - self.liquidity_pool_deposit_result, - self.liquidity_pool_withdraw_result, - self.invoke_host_function_result, - self.bump_footprint_expiration_result, - self.restore_footprint_result, - ) - ) - + return hash((self.type, self.create_account_result, self.payment_result, self.path_payment_strict_receive_result, self.manage_sell_offer_result, self.create_passive_sell_offer_result, self.set_options_result, self.change_trust_result, self.allow_trust_result, self.account_merge_result, self.inflation_result, self.manage_data_result, self.bump_seq_result, self.manage_buy_offer_result, self.path_payment_strict_send_result, self.create_claimable_balance_result, self.claim_claimable_balance_result, self.begin_sponsoring_future_reserves_result, self.end_sponsoring_future_reserves_result, self.revoke_sponsorship_result, self.clawback_result, self.clawback_claimable_balance_result, self.set_trust_line_flags_result, self.liquidity_pool_deposit_result, self.liquidity_pool_withdraw_result, self.invoke_host_function_result, self.bump_footprint_expiration_result, self.restore_footprint_result,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.create_account_result == other.create_account_result - and self.payment_result == other.payment_result - and self.path_payment_strict_receive_result - == other.path_payment_strict_receive_result - and self.manage_sell_offer_result == other.manage_sell_offer_result - and self.create_passive_sell_offer_result - == other.create_passive_sell_offer_result - and self.set_options_result == other.set_options_result - and self.change_trust_result == other.change_trust_result - and self.allow_trust_result == other.allow_trust_result - and self.account_merge_result == other.account_merge_result - and self.inflation_result == other.inflation_result - and self.manage_data_result == other.manage_data_result - and self.bump_seq_result == other.bump_seq_result - and self.manage_buy_offer_result == other.manage_buy_offer_result - and self.path_payment_strict_send_result - == other.path_payment_strict_send_result - and self.create_claimable_balance_result - == other.create_claimable_balance_result - and self.claim_claimable_balance_result - == other.claim_claimable_balance_result - and self.begin_sponsoring_future_reserves_result - == other.begin_sponsoring_future_reserves_result - and self.end_sponsoring_future_reserves_result - == other.end_sponsoring_future_reserves_result - and self.revoke_sponsorship_result == other.revoke_sponsorship_result - and self.clawback_result == other.clawback_result - and self.clawback_claimable_balance_result - == other.clawback_claimable_balance_result - and self.set_trust_line_flags_result == other.set_trust_line_flags_result - and self.liquidity_pool_deposit_result - == other.liquidity_pool_deposit_result - and self.liquidity_pool_withdraw_result - == other.liquidity_pool_withdraw_result - and self.invoke_host_function_result == other.invoke_host_function_result - and self.bump_footprint_expiration_result - == other.bump_footprint_expiration_result - and self.restore_footprint_result == other.restore_footprint_result - ) - + return self.type== other.type and self.create_account_result== other.create_account_result and self.payment_result== other.payment_result and self.path_payment_strict_receive_result== other.path_payment_strict_receive_result and self.manage_sell_offer_result== other.manage_sell_offer_result and self.create_passive_sell_offer_result== other.create_passive_sell_offer_result and self.set_options_result== other.set_options_result and self.change_trust_result== other.change_trust_result and self.allow_trust_result== other.allow_trust_result and self.account_merge_result== other.account_merge_result and self.inflation_result== other.inflation_result and self.manage_data_result== other.manage_data_result and self.bump_seq_result== other.bump_seq_result and self.manage_buy_offer_result== other.manage_buy_offer_result and self.path_payment_strict_send_result== other.path_payment_strict_send_result and self.create_claimable_balance_result== other.create_claimable_balance_result and self.claim_claimable_balance_result== other.claim_claimable_balance_result and self.begin_sponsoring_future_reserves_result== other.begin_sponsoring_future_reserves_result and self.end_sponsoring_future_reserves_result== other.end_sponsoring_future_reserves_result and self.revoke_sponsorship_result== other.revoke_sponsorship_result and self.clawback_result== other.clawback_result and self.clawback_claimable_balance_result== other.clawback_claimable_balance_result and self.set_trust_line_flags_result== other.set_trust_line_flags_result and self.liquidity_pool_deposit_result== other.liquidity_pool_deposit_result and self.liquidity_pool_withdraw_result== other.liquidity_pool_withdraw_result and self.invoke_host_function_result== other.invoke_host_function_result and self.bump_footprint_expiration_result== other.bump_footprint_expiration_result and self.restore_footprint_result== other.restore_footprint_result def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"create_account_result={self.create_account_result}" - ) if self.create_account_result is not None else None - out.append( - f"payment_result={self.payment_result}" - ) if self.payment_result is not None else None - out.append( - f"path_payment_strict_receive_result={self.path_payment_strict_receive_result}" - ) if self.path_payment_strict_receive_result is not None else None - out.append( - f"manage_sell_offer_result={self.manage_sell_offer_result}" - ) if self.manage_sell_offer_result is not None else None - out.append( - f"create_passive_sell_offer_result={self.create_passive_sell_offer_result}" - ) if self.create_passive_sell_offer_result is not None else None - out.append( - f"set_options_result={self.set_options_result}" - ) if self.set_options_result is not None else None - out.append( - f"change_trust_result={self.change_trust_result}" - ) if self.change_trust_result is not None else None - out.append( - f"allow_trust_result={self.allow_trust_result}" - ) if self.allow_trust_result is not None else None - out.append( - f"account_merge_result={self.account_merge_result}" - ) if self.account_merge_result is not None else None - out.append( - f"inflation_result={self.inflation_result}" - ) if self.inflation_result is not None else None - out.append( - f"manage_data_result={self.manage_data_result}" - ) if self.manage_data_result is not None else None - out.append( - f"bump_seq_result={self.bump_seq_result}" - ) if self.bump_seq_result is not None else None - out.append( - f"manage_buy_offer_result={self.manage_buy_offer_result}" - ) if self.manage_buy_offer_result is not None else None - out.append( - f"path_payment_strict_send_result={self.path_payment_strict_send_result}" - ) if self.path_payment_strict_send_result is not None else None - out.append( - f"create_claimable_balance_result={self.create_claimable_balance_result}" - ) if self.create_claimable_balance_result is not None else None - out.append( - f"claim_claimable_balance_result={self.claim_claimable_balance_result}" - ) if self.claim_claimable_balance_result is not None else None - out.append( - f"begin_sponsoring_future_reserves_result={self.begin_sponsoring_future_reserves_result}" - ) if self.begin_sponsoring_future_reserves_result is not None else None - out.append( - f"end_sponsoring_future_reserves_result={self.end_sponsoring_future_reserves_result}" - ) if self.end_sponsoring_future_reserves_result is not None else None - out.append( - f"revoke_sponsorship_result={self.revoke_sponsorship_result}" - ) if self.revoke_sponsorship_result is not None else None - out.append( - f"clawback_result={self.clawback_result}" - ) if self.clawback_result is not None else None - out.append( - f"clawback_claimable_balance_result={self.clawback_claimable_balance_result}" - ) if self.clawback_claimable_balance_result is not None else None - out.append( - f"set_trust_line_flags_result={self.set_trust_line_flags_result}" - ) if self.set_trust_line_flags_result is not None else None - out.append( - f"liquidity_pool_deposit_result={self.liquidity_pool_deposit_result}" - ) if self.liquidity_pool_deposit_result is not None else None - out.append( - f"liquidity_pool_withdraw_result={self.liquidity_pool_withdraw_result}" - ) if self.liquidity_pool_withdraw_result is not None else None - out.append( - f"invoke_host_function_result={self.invoke_host_function_result}" - ) if self.invoke_host_function_result is not None else None - out.append( - f"bump_footprint_expiration_result={self.bump_footprint_expiration_result}" - ) if self.bump_footprint_expiration_result is not None else None - out.append( - f"restore_footprint_result={self.restore_footprint_result}" - ) if self.restore_footprint_result is not None else None + out.append(f'type={self.type}') + out.append(f'create_account_result={self.create_account_result}') if self.create_account_result is not None else None + out.append(f'payment_result={self.payment_result}') if self.payment_result is not None else None + out.append(f'path_payment_strict_receive_result={self.path_payment_strict_receive_result}') if self.path_payment_strict_receive_result is not None else None + out.append(f'manage_sell_offer_result={self.manage_sell_offer_result}') if self.manage_sell_offer_result is not None else None + out.append(f'create_passive_sell_offer_result={self.create_passive_sell_offer_result}') if self.create_passive_sell_offer_result is not None else None + out.append(f'set_options_result={self.set_options_result}') if self.set_options_result is not None else None + out.append(f'change_trust_result={self.change_trust_result}') if self.change_trust_result is not None else None + out.append(f'allow_trust_result={self.allow_trust_result}') if self.allow_trust_result is not None else None + out.append(f'account_merge_result={self.account_merge_result}') if self.account_merge_result is not None else None + out.append(f'inflation_result={self.inflation_result}') if self.inflation_result is not None else None + out.append(f'manage_data_result={self.manage_data_result}') if self.manage_data_result is not None else None + out.append(f'bump_seq_result={self.bump_seq_result}') if self.bump_seq_result is not None else None + out.append(f'manage_buy_offer_result={self.manage_buy_offer_result}') if self.manage_buy_offer_result is not None else None + out.append(f'path_payment_strict_send_result={self.path_payment_strict_send_result}') if self.path_payment_strict_send_result is not None else None + out.append(f'create_claimable_balance_result={self.create_claimable_balance_result}') if self.create_claimable_balance_result is not None else None + out.append(f'claim_claimable_balance_result={self.claim_claimable_balance_result}') if self.claim_claimable_balance_result is not None else None + out.append(f'begin_sponsoring_future_reserves_result={self.begin_sponsoring_future_reserves_result}') if self.begin_sponsoring_future_reserves_result is not None else None + out.append(f'end_sponsoring_future_reserves_result={self.end_sponsoring_future_reserves_result}') if self.end_sponsoring_future_reserves_result is not None else None + out.append(f'revoke_sponsorship_result={self.revoke_sponsorship_result}') if self.revoke_sponsorship_result is not None else None + out.append(f'clawback_result={self.clawback_result}') if self.clawback_result is not None else None + out.append(f'clawback_claimable_balance_result={self.clawback_claimable_balance_result}') if self.clawback_claimable_balance_result is not None else None + out.append(f'set_trust_line_flags_result={self.set_trust_line_flags_result}') if self.set_trust_line_flags_result is not None else None + out.append(f'liquidity_pool_deposit_result={self.liquidity_pool_deposit_result}') if self.liquidity_pool_deposit_result is not None else None + out.append(f'liquidity_pool_withdraw_result={self.liquidity_pool_withdraw_result}') if self.liquidity_pool_withdraw_result is not None else None + out.append(f'invoke_host_function_result={self.invoke_host_function_result}') if self.invoke_host_function_result is not None else None + out.append(f'bump_footprint_expiration_result={self.bump_footprint_expiration_result}') if self.bump_footprint_expiration_result is not None else None + out.append(f'restore_footprint_result={self.restore_footprint_result}') if self.restore_footprint_result is not None else None return f"" diff --git a/stellar_sdk/xdr/operation_type.py b/stellar_sdk/xdr/operation_type.py index cc8810e6..5ee82cb5 100644 --- a/stellar_sdk/xdr/operation_type.py +++ b/stellar_sdk/xdr/operation_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["OperationType"] - - +__all__ = ['OperationType'] class OperationType(IntEnum): """ XDR Source Code:: @@ -45,7 +45,6 @@ class OperationType(IntEnum): RESTORE_FOOTPRINT = 26 }; """ - CREATE_ACCOUNT = 0 PAYMENT = 1 PATH_PAYMENT_STRICT_RECEIVE = 2 @@ -73,7 +72,6 @@ class OperationType(IntEnum): INVOKE_HOST_FUNCTION = 24 BUMP_FOOTPRINT_EXPIRATION = 25 RESTORE_FOOTPRINT = 26 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -81,7 +79,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> OperationType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/path_payment_strict_receive_op.py b/stellar_sdk/xdr/path_payment_strict_receive_op.py index ed7a9048..95e43405 100644 --- a/stellar_sdk/xdr/path_payment_strict_receive_op.py +++ b/stellar_sdk/xdr/path_payment_strict_receive_op.py @@ -3,17 +3,19 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .asset import Asset from .int64 import Int64 from .muxed_account import MuxedAccount - -__all__ = ["PathPaymentStrictReceiveOp"] - - +from .asset import Asset +from .int64 import Int64 +from .asset import Asset +__all__ = ['PathPaymentStrictReceiveOp'] class PathPaymentStrictReceiveOp: """ XDR Source Code:: @@ -32,7 +34,6 @@ class PathPaymentStrictReceiveOp: Asset path<5>; // additional hops it must go through to get there }; """ - def __init__( self, send_asset: Asset, @@ -44,16 +45,13 @@ def __init__( ) -> None: _expect_max_length = 5 if path and len(path) > _expect_max_length: - raise ValueError( - f"The maximum length of `path` should be {_expect_max_length}, but got {len(path)}." - ) + raise ValueError(f"The maximum length of `path` should be {_expect_max_length}, but got {len(path)}.") self.send_asset = send_asset self.send_max = send_max self.destination = destination self.dest_asset = dest_asset self.dest_amount = dest_amount self.path = path - def pack(self, packer: Packer) -> None: self.send_asset.pack(packer) self.send_max.pack(packer) @@ -63,7 +61,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.path)) for path_item in self.path: path_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictReceiveOp: send_asset = Asset.unpack(unpacker) @@ -83,7 +80,6 @@ def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictReceiveOp: dest_amount=dest_amount, path=path, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,38 +98,19 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PathPaymentStrictReceiveOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.send_asset, - self.send_max, - self.destination, - self.dest_asset, - self.dest_amount, - self.path, - ) - ) - + return hash((self.send_asset, self.send_max, self.destination, self.dest_asset, self.dest_amount, self.path,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.send_asset == other.send_asset - and self.send_max == other.send_max - and self.destination == other.destination - and self.dest_asset == other.dest_asset - and self.dest_amount == other.dest_amount - and self.path == other.path - ) - + return self.send_asset== other.send_asset and self.send_max== other.send_max and self.destination== other.destination and self.dest_asset== other.dest_asset and self.dest_amount== other.dest_amount and self.path== other.path def __str__(self): out = [ - f"send_asset={self.send_asset}", - f"send_max={self.send_max}", - f"destination={self.destination}", - f"dest_asset={self.dest_asset}", - f"dest_amount={self.dest_amount}", - f"path={self.path}", + f'send_asset={self.send_asset}', + f'send_max={self.send_max}', + f'destination={self.destination}', + f'dest_asset={self.dest_asset}', + f'dest_amount={self.dest_amount}', + f'path={self.path}', ] return f"" diff --git a/stellar_sdk/xdr/path_payment_strict_receive_result.py b/stellar_sdk/xdr/path_payment_strict_receive_result.py index 56fbd91b..c3c2ad2f 100644 --- a/stellar_sdk/xdr/path_payment_strict_receive_result.py +++ b/stellar_sdk/xdr/path_payment_strict_receive_result.py @@ -3,18 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .asset import Asset from .path_payment_strict_receive_result_code import PathPaymentStrictReceiveResultCode -from .path_payment_strict_receive_result_success import ( - PathPaymentStrictReceiveResultSuccess, -) - -__all__ = ["PathPaymentStrictReceiveResult"] - - +from .path_payment_strict_receive_result_success import PathPaymentStrictReceiveResultSuccess +from .asset import Asset +__all__ = ['PathPaymentStrictReceiveResult'] class PathPaymentStrictReceiveResult: """ XDR Source Code:: @@ -45,7 +43,6 @@ class PathPaymentStrictReceiveResult: void; }; """ - def __init__( self, code: PathPaymentStrictReceiveResultCode, @@ -55,153 +52,72 @@ def __init__( self.code = code self.success = success self.no_issuer = no_issuer - def pack(self, packer: Packer) -> None: self.code.pack(packer) - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SUCCESS - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SUCCESS: if self.success is None: raise ValueError("success should not be None.") self.success.pack(packer) return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_MALFORMED - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_MALFORMED: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER: if self.no_issuer is None: raise ValueError("no_issuer should not be None.") self.no_issuer.pack(packer) return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF: return - if ( - self.code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX - ): + if self.code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX: return - @classmethod def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictReceiveResult: code = PathPaymentStrictReceiveResultCode.unpack(unpacker) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SUCCESS - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SUCCESS: success = PathPaymentStrictReceiveResultSuccess.unpack(unpacker) return cls(code=code, success=success) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_MALFORMED - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_MALFORMED: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER: no_issuer = Asset.unpack(unpacker) return cls(code=code, no_issuer=no_issuer) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF: return cls(code=code) - if ( - code - == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX - ): + if code == PathPaymentStrictReceiveResultCode.PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -220,30 +136,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PathPaymentStrictReceiveResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.success, - self.no_issuer, - ) - ) - + return hash((self.code, self.success, self.no_issuer,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.code == other.code - and self.success == other.success - and self.no_issuer == other.no_issuer - ) - + return self.code== other.code and self.success== other.success and self.no_issuer== other.no_issuer def __str__(self): out = [] - out.append(f"code={self.code}") - out.append(f"success={self.success}") if self.success is not None else None - out.append( - f"no_issuer={self.no_issuer}" - ) if self.no_issuer is not None else None + out.append(f'code={self.code}') + out.append(f'success={self.success}') if self.success is not None else None + out.append(f'no_issuer={self.no_issuer}') if self.no_issuer is not None else None return f"" diff --git a/stellar_sdk/xdr/path_payment_strict_receive_result_code.py b/stellar_sdk/xdr/path_payment_strict_receive_result_code.py index 4b209156..347df51f 100644 --- a/stellar_sdk/xdr/path_payment_strict_receive_result_code.py +++ b/stellar_sdk/xdr/path_payment_strict_receive_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["PathPaymentStrictReceiveResultCode"] - - +__all__ = ['PathPaymentStrictReceiveResultCode'] class PathPaymentStrictReceiveResultCode(IntEnum): """ XDR Source Code:: @@ -43,7 +43,6 @@ class PathPaymentStrictReceiveResultCode(IntEnum): PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX = -12 // could not satisfy sendmax }; """ - PATH_PAYMENT_STRICT_RECEIVE_SUCCESS = 0 PATH_PAYMENT_STRICT_RECEIVE_MALFORMED = -1 PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED = -2 @@ -57,7 +56,6 @@ class PathPaymentStrictReceiveResultCode(IntEnum): PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS = -10 PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF = -11 PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX = -12 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -65,7 +63,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictReceiveResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/path_payment_strict_receive_result_success.py b/stellar_sdk/xdr/path_payment_strict_receive_result_success.py index 69dc965b..6ebd2bcf 100644 --- a/stellar_sdk/xdr/path_payment_strict_receive_result_success.py +++ b/stellar_sdk/xdr/path_payment_strict_receive_result_success.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claim_atom import ClaimAtom from .simple_payment_result import SimplePaymentResult - -__all__ = ["PathPaymentStrictReceiveResultSuccess"] - - +__all__ = ['PathPaymentStrictReceiveResultSuccess'] class PathPaymentStrictReceiveResultSuccess: """ XDR Source Code:: @@ -23,7 +22,6 @@ class PathPaymentStrictReceiveResultSuccess: SimplePaymentResult last; } """ - def __init__( self, offers: List[ClaimAtom], @@ -31,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if offers and len(offers) > _expect_max_length: - raise ValueError( - f"The maximum length of `offers` should be {_expect_max_length}, but got {len(offers)}." - ) + raise ValueError(f"The maximum length of `offers` should be {_expect_max_length}, but got {len(offers)}.") self.offers = offers self.last = last - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.offers)) for offers_item in self.offers: offers_item.pack(packer) self.last.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictReceiveResultSuccess: length = unpacker.unpack_uint() @@ -54,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictReceiveResultSuccess: offers=offers, last=last, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,23 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PathPaymentStrictReceiveResultSuccess: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.offers, - self.last, - ) - ) - + return hash((self.offers, self.last,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.offers == other.offers and self.last == other.last - + return self.offers== other.offers and self.last== other.last def __str__(self): out = [ - f"offers={self.offers}", - f"last={self.last}", + f'offers={self.offers}', + f'last={self.last}', ] return f"" diff --git a/stellar_sdk/xdr/path_payment_strict_send_op.py b/stellar_sdk/xdr/path_payment_strict_send_op.py index 8234e5ae..51343d7f 100644 --- a/stellar_sdk/xdr/path_payment_strict_send_op.py +++ b/stellar_sdk/xdr/path_payment_strict_send_op.py @@ -3,17 +3,19 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .asset import Asset from .int64 import Int64 from .muxed_account import MuxedAccount - -__all__ = ["PathPaymentStrictSendOp"] - - +from .asset import Asset +from .int64 import Int64 +from .asset import Asset +__all__ = ['PathPaymentStrictSendOp'] class PathPaymentStrictSendOp: """ XDR Source Code:: @@ -32,7 +34,6 @@ class PathPaymentStrictSendOp: Asset path<5>; // additional hops it must go through to get there }; """ - def __init__( self, send_asset: Asset, @@ -44,16 +45,13 @@ def __init__( ) -> None: _expect_max_length = 5 if path and len(path) > _expect_max_length: - raise ValueError( - f"The maximum length of `path` should be {_expect_max_length}, but got {len(path)}." - ) + raise ValueError(f"The maximum length of `path` should be {_expect_max_length}, but got {len(path)}.") self.send_asset = send_asset self.send_amount = send_amount self.destination = destination self.dest_asset = dest_asset self.dest_min = dest_min self.path = path - def pack(self, packer: Packer) -> None: self.send_asset.pack(packer) self.send_amount.pack(packer) @@ -63,7 +61,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.path)) for path_item in self.path: path_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictSendOp: send_asset = Asset.unpack(unpacker) @@ -83,7 +80,6 @@ def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictSendOp: dest_min=dest_min, path=path, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,38 +98,19 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PathPaymentStrictSendOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.send_asset, - self.send_amount, - self.destination, - self.dest_asset, - self.dest_min, - self.path, - ) - ) - + return hash((self.send_asset, self.send_amount, self.destination, self.dest_asset, self.dest_min, self.path,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.send_asset == other.send_asset - and self.send_amount == other.send_amount - and self.destination == other.destination - and self.dest_asset == other.dest_asset - and self.dest_min == other.dest_min - and self.path == other.path - ) - + return self.send_asset== other.send_asset and self.send_amount== other.send_amount and self.destination== other.destination and self.dest_asset== other.dest_asset and self.dest_min== other.dest_min and self.path== other.path def __str__(self): out = [ - f"send_asset={self.send_asset}", - f"send_amount={self.send_amount}", - f"destination={self.destination}", - f"dest_asset={self.dest_asset}", - f"dest_min={self.dest_min}", - f"path={self.path}", + f'send_asset={self.send_asset}', + f'send_amount={self.send_amount}', + f'destination={self.destination}', + f'dest_asset={self.dest_asset}', + f'dest_min={self.dest_min}', + f'path={self.path}', ] return f"" diff --git a/stellar_sdk/xdr/path_payment_strict_send_result.py b/stellar_sdk/xdr/path_payment_strict_send_result.py index 354c7003..bf6e09e7 100644 --- a/stellar_sdk/xdr/path_payment_strict_send_result.py +++ b/stellar_sdk/xdr/path_payment_strict_send_result.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .asset import Asset from .path_payment_strict_send_result_code import PathPaymentStrictSendResultCode from .path_payment_strict_send_result_success import PathPaymentStrictSendResultSuccess - -__all__ = ["PathPaymentStrictSendResult"] - - +from .asset import Asset +__all__ = ['PathPaymentStrictSendResult'] class PathPaymentStrictSendResult: """ XDR Source Code:: @@ -42,7 +42,6 @@ class PathPaymentStrictSendResult: void; }; """ - def __init__( self, code: PathPaymentStrictSendResultCode, @@ -52,81 +51,40 @@ def __init__( self.code = code self.success = success self.no_issuer = no_issuer - def pack(self, packer: Packer) -> None: self.code.pack(packer) - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SUCCESS - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SUCCESS: if self.success is None: raise ValueError("success should not be None.") self.success.pack(packer) return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_MALFORMED - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_MALFORMED: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_UNDERFUNDED - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_UNDERFUNDED: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_DESTINATION - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_DESTINATION: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_TRUST - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_TRUST: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_LINE_FULL - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_LINE_FULL: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_ISSUER - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_ISSUER: if self.no_issuer is None: raise ValueError("no_issuer should not be None.") self.no_issuer.pack(packer) return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF: return - if ( - self.code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN - ): + if self.code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN: return - @classmethod def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictSendResult: code = PathPaymentStrictSendResultCode.unpack(unpacker) @@ -137,50 +95,28 @@ def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictSendResult: return cls(code=code) if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_UNDERFUNDED: return cls(code=code) - if ( - code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST - ): + if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST: return cls(code=code) - if ( - code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED - ): + if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED: return cls(code=code) - if ( - code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_DESTINATION - ): + if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_DESTINATION: return cls(code=code) if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_TRUST: return cls(code=code) - if ( - code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED - ): + if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED: return cls(code=code) if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_LINE_FULL: return cls(code=code) if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_NO_ISSUER: no_issuer = Asset.unpack(unpacker) return cls(code=code, no_issuer=no_issuer) - if ( - code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS - ): + if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS: return cls(code=code) - if ( - code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF - ): + if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF: return cls(code=code) - if ( - code - == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN - ): + if code == PathPaymentStrictSendResultCode.PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -199,30 +135,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PathPaymentStrictSendResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.success, - self.no_issuer, - ) - ) - + return hash((self.code, self.success, self.no_issuer,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.code == other.code - and self.success == other.success - and self.no_issuer == other.no_issuer - ) - + return self.code== other.code and self.success== other.success and self.no_issuer== other.no_issuer def __str__(self): out = [] - out.append(f"code={self.code}") - out.append(f"success={self.success}") if self.success is not None else None - out.append( - f"no_issuer={self.no_issuer}" - ) if self.no_issuer is not None else None + out.append(f'code={self.code}') + out.append(f'success={self.success}') if self.success is not None else None + out.append(f'no_issuer={self.no_issuer}') if self.no_issuer is not None else None return f"" diff --git a/stellar_sdk/xdr/path_payment_strict_send_result_code.py b/stellar_sdk/xdr/path_payment_strict_send_result_code.py index 0a370b92..b81dab53 100644 --- a/stellar_sdk/xdr/path_payment_strict_send_result_code.py +++ b/stellar_sdk/xdr/path_payment_strict_send_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["PathPaymentStrictSendResultCode"] - - +__all__ = ['PathPaymentStrictSendResultCode'] class PathPaymentStrictSendResultCode(IntEnum): """ XDR Source Code:: @@ -42,7 +42,6 @@ class PathPaymentStrictSendResultCode(IntEnum): PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN = -12 // could not satisfy destMin }; """ - PATH_PAYMENT_STRICT_SEND_SUCCESS = 0 PATH_PAYMENT_STRICT_SEND_MALFORMED = -1 PATH_PAYMENT_STRICT_SEND_UNDERFUNDED = -2 @@ -56,7 +55,6 @@ class PathPaymentStrictSendResultCode(IntEnum): PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS = -10 PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF = -11 PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN = -12 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -64,7 +62,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictSendResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/path_payment_strict_send_result_success.py b/stellar_sdk/xdr/path_payment_strict_send_result_success.py index 51d70d77..4a609028 100644 --- a/stellar_sdk/xdr/path_payment_strict_send_result_success.py +++ b/stellar_sdk/xdr/path_payment_strict_send_result_success.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .claim_atom import ClaimAtom from .simple_payment_result import SimplePaymentResult - -__all__ = ["PathPaymentStrictSendResultSuccess"] - - +__all__ = ['PathPaymentStrictSendResultSuccess'] class PathPaymentStrictSendResultSuccess: """ XDR Source Code:: @@ -23,7 +22,6 @@ class PathPaymentStrictSendResultSuccess: SimplePaymentResult last; } """ - def __init__( self, offers: List[ClaimAtom], @@ -31,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if offers and len(offers) > _expect_max_length: - raise ValueError( - f"The maximum length of `offers` should be {_expect_max_length}, but got {len(offers)}." - ) + raise ValueError(f"The maximum length of `offers` should be {_expect_max_length}, but got {len(offers)}.") self.offers = offers self.last = last - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.offers)) for offers_item in self.offers: offers_item.pack(packer) self.last.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictSendResultSuccess: length = unpacker.unpack_uint() @@ -54,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> PathPaymentStrictSendResultSuccess: offers=offers, last=last, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,23 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PathPaymentStrictSendResultSuccess: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.offers, - self.last, - ) - ) - + return hash((self.offers, self.last,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.offers == other.offers and self.last == other.last - + return self.offers== other.offers and self.last== other.last def __str__(self): out = [ - f"offers={self.offers}", - f"last={self.last}", + f'offers={self.offers}', + f'last={self.last}', ] return f"" diff --git a/stellar_sdk/xdr/payment_op.py b/stellar_sdk/xdr/payment_op.py index aea398ff..94d64a04 100644 --- a/stellar_sdk/xdr/payment_op.py +++ b/stellar_sdk/xdr/payment_op.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .muxed_account import MuxedAccount from .asset import Asset from .int64 import Int64 -from .muxed_account import MuxedAccount - -__all__ = ["PaymentOp"] - - +__all__ = ['PaymentOp'] class PaymentOp: """ XDR Source Code:: @@ -24,7 +24,6 @@ class PaymentOp: int64 amount; // amount they end up with }; """ - def __init__( self, destination: MuxedAccount, @@ -34,12 +33,10 @@ def __init__( self.destination = destination self.asset = asset self.amount = amount - def pack(self, packer: Packer) -> None: self.destination.pack(packer) self.asset.pack(packer) self.amount.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PaymentOp: destination = MuxedAccount.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> PaymentOp: asset=asset, amount=amount, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PaymentOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.destination, - self.asset, - self.amount, - ) - ) - + return hash((self.destination, self.asset, self.amount,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.destination == other.destination - and self.asset == other.asset - and self.amount == other.amount - ) - + return self.destination== other.destination and self.asset== other.asset and self.amount== other.amount def __str__(self): out = [ - f"destination={self.destination}", - f"asset={self.asset}", - f"amount={self.amount}", + f'destination={self.destination}', + f'asset={self.asset}', + f'amount={self.amount}', ] return f"" diff --git a/stellar_sdk/xdr/payment_result.py b/stellar_sdk/xdr/payment_result.py index fc881bdb..9aace64b 100644 --- a/stellar_sdk/xdr/payment_result.py +++ b/stellar_sdk/xdr/payment_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .payment_result_code import PaymentResultCode - -__all__ = ["PaymentResult"] - - +__all__ = ['PaymentResult'] class PaymentResult: """ XDR Source Code:: @@ -31,13 +31,11 @@ class PaymentResult: void; }; """ - def __init__( self, code: PaymentResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == PaymentResultCode.PAYMENT_SUCCESS: @@ -60,7 +58,6 @@ def pack(self, packer: Packer) -> None: return if self.code == PaymentResultCode.PAYMENT_NO_ISSUER: return - @classmethod def unpack(cls, unpacker: Unpacker) -> PaymentResult: code = PaymentResultCode.unpack(unpacker) @@ -85,7 +82,6 @@ def unpack(cls, unpacker: Unpacker) -> PaymentResult: if code == PaymentResultCode.PAYMENT_NO_ISSUER: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -104,16 +100,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PaymentResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/payment_result_code.py b/stellar_sdk/xdr/payment_result_code.py index dc42e050..b3593764 100644 --- a/stellar_sdk/xdr/payment_result_code.py +++ b/stellar_sdk/xdr/payment_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["PaymentResultCode"] - - +__all__ = ['PaymentResultCode'] class PaymentResultCode(IntEnum): """ XDR Source Code:: @@ -31,7 +31,6 @@ class PaymentResultCode(IntEnum): PAYMENT_NO_ISSUER = -9 // missing issuer on asset }; """ - PAYMENT_SUCCESS = 0 PAYMENT_MALFORMED = -1 PAYMENT_UNDERFUNDED = -2 @@ -42,7 +41,6 @@ class PaymentResultCode(IntEnum): PAYMENT_NOT_AUTHORIZED = -7 PAYMENT_LINE_FULL = -8 PAYMENT_NO_ISSUER = -9 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -50,7 +48,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> PaymentResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/peer_address.py b/stellar_sdk/xdr/peer_address.py index 21a223f3..6f9ce992 100644 --- a/stellar_sdk/xdr/peer_address.py +++ b/stellar_sdk/xdr/peer_address.py @@ -3,15 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .peer_address_ip import PeerAddressIp from .uint32 import Uint32 - -__all__ = ["PeerAddress"] - - +from .uint32 import Uint32 +__all__ = ['PeerAddress'] class PeerAddress: """ XDR Source Code:: @@ -30,7 +31,6 @@ class PeerAddress: uint32 numFailures; }; """ - def __init__( self, ip: PeerAddressIp, @@ -40,12 +40,10 @@ def __init__( self.ip = ip self.port = port self.num_failures = num_failures - def pack(self, packer: Packer) -> None: self.ip.pack(packer) self.port.pack(packer) self.num_failures.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PeerAddress: ip = PeerAddressIp.unpack(unpacker) @@ -56,7 +54,6 @@ def unpack(cls, unpacker: Unpacker) -> PeerAddress: port=port, num_failures=num_failures, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -75,29 +72,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PeerAddress: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ip, - self.port, - self.num_failures, - ) - ) - + return hash((self.ip, self.port, self.num_failures,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ip == other.ip - and self.port == other.port - and self.num_failures == other.num_failures - ) - + return self.ip== other.ip and self.port== other.port and self.num_failures== other.num_failures def __str__(self): out = [ - f"ip={self.ip}", - f"port={self.port}", - f"num_failures={self.num_failures}", + f'ip={self.ip}', + f'port={self.port}', + f'num_failures={self.num_failures}', ] return f"" diff --git a/stellar_sdk/xdr/peer_address_ip.py b/stellar_sdk/xdr/peer_address_ip.py index 70d69f47..ec566ecb 100644 --- a/stellar_sdk/xdr/peer_address_ip.py +++ b/stellar_sdk/xdr/peer_address_ip.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque from .ip_addr_type import IPAddrType - -__all__ = ["PeerAddressIp"] - - +__all__ = ['PeerAddressIp'] class PeerAddressIp: """ XDR Source Code:: @@ -24,7 +23,6 @@ class PeerAddressIp: opaque ipv6[16]; } """ - def __init__( self, type: IPAddrType, @@ -34,7 +32,6 @@ def __init__( self.type = type self.ipv4 = ipv4 self.ipv6 = ipv6 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == IPAddrType.IPv4: @@ -47,7 +44,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("ipv6 should not be None.") Opaque(self.ipv6, 16, True).pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> PeerAddressIp: type = IPAddrType.unpack(unpacker) @@ -58,7 +54,6 @@ def unpack(cls, unpacker: Unpacker) -> PeerAddressIp: ipv6 = Opaque.unpack(unpacker, 16, True) return cls(type=type, ipv6=ipv6) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -77,28 +72,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PeerAddressIp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.ipv4, - self.ipv6, - ) - ) - + return hash((self.type, self.ipv4, self.ipv6,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.ipv4 == other.ipv4 - and self.ipv6 == other.ipv6 - ) - + return self.type== other.type and self.ipv4== other.ipv4 and self.ipv6== other.ipv6 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"ipv4={self.ipv4}") if self.ipv4 is not None else None - out.append(f"ipv6={self.ipv6}") if self.ipv6 is not None else None + out.append(f'type={self.type}') + out.append(f'ipv4={self.ipv4}') if self.ipv4 is not None else None + out.append(f'ipv6={self.ipv6}') if self.ipv6 is not None else None return f"" diff --git a/stellar_sdk/xdr/peer_stat_list.py b/stellar_sdk/xdr/peer_stat_list.py index b07c35f9..ff477261 100644 --- a/stellar_sdk/xdr/peer_stat_list.py +++ b/stellar_sdk/xdr/peer_stat_list.py @@ -3,35 +3,29 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .peer_stats import PeerStats - -__all__ = ["PeerStatList"] - - +__all__ = ['PeerStatList'] class PeerStatList: """ XDR Source Code:: typedef PeerStats PeerStatList<25>; """ - def __init__(self, peer_stat_list: List[PeerStats]) -> None: _expect_max_length = 25 if peer_stat_list and len(peer_stat_list) > _expect_max_length: - raise ValueError( - f"The maximum length of `peer_stat_list` should be {_expect_max_length}, but got {len(peer_stat_list)}." - ) + raise ValueError(f"The maximum length of `peer_stat_list` should be {_expect_max_length}, but got {len(peer_stat_list)}.") self.peer_stat_list = peer_stat_list - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.peer_stat_list)) for peer_stat_list_item in self.peer_stat_list: peer_stat_list_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PeerStatList: length = unpacker.unpack_uint() @@ -39,7 +33,6 @@ def unpack(cls, unpacker: Unpacker) -> PeerStatList: for _ in range(length): peer_stat_list.append(PeerStats.unpack(unpacker)) return cls(peer_stat_list) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,10 +51,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PeerStatList: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.peer_stat_list) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/peer_stats.py b/stellar_sdk/xdr/peer_stats.py index 21d1183c..29c55a51 100644 --- a/stellar_sdk/xdr/peer_stats.py +++ b/stellar_sdk/xdr/peer_stats.py @@ -3,16 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import String from .node_id import NodeID from .uint64 import Uint64 - -__all__ = ["PeerStats"] - - +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +__all__ = ['PeerStats'] class PeerStats: """ XDR Source Code:: @@ -38,7 +49,6 @@ class PeerStats: uint64 duplicateFetchMessageRecv; }; """ - def __init__( self, id: NodeID, @@ -72,7 +82,6 @@ def __init__( self.duplicate_flood_message_recv = duplicate_flood_message_recv self.unique_fetch_message_recv = unique_fetch_message_recv self.duplicate_fetch_message_recv = duplicate_fetch_message_recv - def pack(self, packer: Packer) -> None: self.id.pack(packer) String(self.version_str, 100).pack(packer) @@ -89,7 +98,6 @@ def pack(self, packer: Packer) -> None: self.duplicate_flood_message_recv.pack(packer) self.unique_fetch_message_recv.pack(packer) self.duplicate_fetch_message_recv.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PeerStats: id = NodeID.unpack(unpacker) @@ -124,7 +132,6 @@ def unpack(cls, unpacker: Unpacker) -> PeerStats: unique_fetch_message_recv=unique_fetch_message_recv, duplicate_fetch_message_recv=duplicate_fetch_message_recv, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -143,65 +150,28 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PeerStats: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.id, - self.version_str, - self.messages_read, - self.messages_written, - self.bytes_read, - self.bytes_written, - self.seconds_connected, - self.unique_flood_bytes_recv, - self.duplicate_flood_bytes_recv, - self.unique_fetch_bytes_recv, - self.duplicate_fetch_bytes_recv, - self.unique_flood_message_recv, - self.duplicate_flood_message_recv, - self.unique_fetch_message_recv, - self.duplicate_fetch_message_recv, - ) - ) - + return hash((self.id, self.version_str, self.messages_read, self.messages_written, self.bytes_read, self.bytes_written, self.seconds_connected, self.unique_flood_bytes_recv, self.duplicate_flood_bytes_recv, self.unique_fetch_bytes_recv, self.duplicate_fetch_bytes_recv, self.unique_flood_message_recv, self.duplicate_flood_message_recv, self.unique_fetch_message_recv, self.duplicate_fetch_message_recv,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.id == other.id - and self.version_str == other.version_str - and self.messages_read == other.messages_read - and self.messages_written == other.messages_written - and self.bytes_read == other.bytes_read - and self.bytes_written == other.bytes_written - and self.seconds_connected == other.seconds_connected - and self.unique_flood_bytes_recv == other.unique_flood_bytes_recv - and self.duplicate_flood_bytes_recv == other.duplicate_flood_bytes_recv - and self.unique_fetch_bytes_recv == other.unique_fetch_bytes_recv - and self.duplicate_fetch_bytes_recv == other.duplicate_fetch_bytes_recv - and self.unique_flood_message_recv == other.unique_flood_message_recv - and self.duplicate_flood_message_recv == other.duplicate_flood_message_recv - and self.unique_fetch_message_recv == other.unique_fetch_message_recv - and self.duplicate_fetch_message_recv == other.duplicate_fetch_message_recv - ) - + return self.id== other.id and self.version_str== other.version_str and self.messages_read== other.messages_read and self.messages_written== other.messages_written and self.bytes_read== other.bytes_read and self.bytes_written== other.bytes_written and self.seconds_connected== other.seconds_connected and self.unique_flood_bytes_recv== other.unique_flood_bytes_recv and self.duplicate_flood_bytes_recv== other.duplicate_flood_bytes_recv and self.unique_fetch_bytes_recv== other.unique_fetch_bytes_recv and self.duplicate_fetch_bytes_recv== other.duplicate_fetch_bytes_recv and self.unique_flood_message_recv== other.unique_flood_message_recv and self.duplicate_flood_message_recv== other.duplicate_flood_message_recv and self.unique_fetch_message_recv== other.unique_fetch_message_recv and self.duplicate_fetch_message_recv== other.duplicate_fetch_message_recv def __str__(self): out = [ - f"id={self.id}", - f"version_str={self.version_str}", - f"messages_read={self.messages_read}", - f"messages_written={self.messages_written}", - f"bytes_read={self.bytes_read}", - f"bytes_written={self.bytes_written}", - f"seconds_connected={self.seconds_connected}", - f"unique_flood_bytes_recv={self.unique_flood_bytes_recv}", - f"duplicate_flood_bytes_recv={self.duplicate_flood_bytes_recv}", - f"unique_fetch_bytes_recv={self.unique_fetch_bytes_recv}", - f"duplicate_fetch_bytes_recv={self.duplicate_fetch_bytes_recv}", - f"unique_flood_message_recv={self.unique_flood_message_recv}", - f"duplicate_flood_message_recv={self.duplicate_flood_message_recv}", - f"unique_fetch_message_recv={self.unique_fetch_message_recv}", - f"duplicate_fetch_message_recv={self.duplicate_fetch_message_recv}", + f'id={self.id}', + f'version_str={self.version_str}', + f'messages_read={self.messages_read}', + f'messages_written={self.messages_written}', + f'bytes_read={self.bytes_read}', + f'bytes_written={self.bytes_written}', + f'seconds_connected={self.seconds_connected}', + f'unique_flood_bytes_recv={self.unique_flood_bytes_recv}', + f'duplicate_flood_bytes_recv={self.duplicate_flood_bytes_recv}', + f'unique_fetch_bytes_recv={self.unique_fetch_bytes_recv}', + f'duplicate_fetch_bytes_recv={self.duplicate_fetch_bytes_recv}', + f'unique_flood_message_recv={self.unique_flood_message_recv}', + f'duplicate_flood_message_recv={self.duplicate_flood_message_recv}', + f'unique_fetch_message_recv={self.unique_fetch_message_recv}', + f'duplicate_fetch_message_recv={self.duplicate_fetch_message_recv}', ] return f"" diff --git a/stellar_sdk/xdr/persisted_scp_state.py b/stellar_sdk/xdr/persisted_scp_state.py index df600642..943049b6 100644 --- a/stellar_sdk/xdr/persisted_scp_state.py +++ b/stellar_sdk/xdr/persisted_scp_state.py @@ -3,29 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .persisted_scp_state_v0 import PersistedSCPStateV0 from .persisted_scp_state_v1 import PersistedSCPStateV1 - -__all__ = ["PersistedSCPState"] - - +__all__ = ['PersistedSCPState'] class PersistedSCPState: """ XDR Source Code:: - union PersistedSCPState switch (int v) - { - case 0: - PersistedSCPStateV0 v0; - case 1: - PersistedSCPStateV1 v1; - }; + union PersistedSCPState switch (int v) + { + case 0: + PersistedSCPStateV0 v0; + case 1: + PersistedSCPStateV1 v1; + }; """ - def __init__( self, v: int, @@ -35,7 +33,6 @@ def __init__( self.v = v self.v0 = v0 self.v1 = v1 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -48,7 +45,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v1 should not be None.") self.v1.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> PersistedSCPState: v = Integer.unpack(unpacker) @@ -59,7 +55,6 @@ def unpack(cls, unpacker: Unpacker) -> PersistedSCPState: v1 = PersistedSCPStateV1.unpack(unpacker) return cls(v=v, v1=v1) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -78,24 +73,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PersistedSCPState: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v0, - self.v1, - ) - ) - + return hash((self.v, self.v0, self.v1,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v0 == other.v0 and self.v1 == other.v1 - + return self.v== other.v and self.v0== other.v0 and self.v1== other.v1 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v0={self.v0}") if self.v0 is not None else None - out.append(f"v1={self.v1}") if self.v1 is not None else None + out.append(f'v={self.v}') + out.append(f'v0={self.v0}') if self.v0 is not None else None + out.append(f'v1={self.v1}') if self.v1 is not None else None return f"" diff --git a/stellar_sdk/xdr/persisted_scp_state_v0.py b/stellar_sdk/xdr/persisted_scp_state_v0.py index e676d7db..2343548e 100644 --- a/stellar_sdk/xdr/persisted_scp_state_v0.py +++ b/stellar_sdk/xdr/persisted_scp_state_v0.py @@ -3,29 +3,27 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .scp_envelope import SCPEnvelope from .scp_quorum_set import SCPQuorumSet from .stored_transaction_set import StoredTransactionSet - -__all__ = ["PersistedSCPStateV0"] - - +__all__ = ['PersistedSCPStateV0'] class PersistedSCPStateV0: """ XDR Source Code:: - struct PersistedSCPStateV0 - { - SCPEnvelope scpEnvelopes<>; - SCPQuorumSet quorumSets<>; - StoredTransactionSet txSets<>; - }; + struct PersistedSCPStateV0 + { + SCPEnvelope scpEnvelopes<>; + SCPQuorumSet quorumSets<>; + StoredTransactionSet txSets<>; + }; """ - def __init__( self, scp_envelopes: List[SCPEnvelope], @@ -34,23 +32,16 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if scp_envelopes and len(scp_envelopes) > _expect_max_length: - raise ValueError( - f"The maximum length of `scp_envelopes` should be {_expect_max_length}, but got {len(scp_envelopes)}." - ) + raise ValueError(f"The maximum length of `scp_envelopes` should be {_expect_max_length}, but got {len(scp_envelopes)}.") _expect_max_length = 4294967295 if quorum_sets and len(quorum_sets) > _expect_max_length: - raise ValueError( - f"The maximum length of `quorum_sets` should be {_expect_max_length}, but got {len(quorum_sets)}." - ) + raise ValueError(f"The maximum length of `quorum_sets` should be {_expect_max_length}, but got {len(quorum_sets)}.") _expect_max_length = 4294967295 if tx_sets and len(tx_sets) > _expect_max_length: - raise ValueError( - f"The maximum length of `tx_sets` should be {_expect_max_length}, but got {len(tx_sets)}." - ) + raise ValueError(f"The maximum length of `tx_sets` should be {_expect_max_length}, but got {len(tx_sets)}.") self.scp_envelopes = scp_envelopes self.quorum_sets = quorum_sets self.tx_sets = tx_sets - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.scp_envelopes)) for scp_envelopes_item in self.scp_envelopes: @@ -61,7 +52,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.tx_sets)) for tx_sets_item in self.tx_sets: tx_sets_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PersistedSCPStateV0: length = unpacker.unpack_uint() @@ -81,7 +71,6 @@ def unpack(cls, unpacker: Unpacker) -> PersistedSCPStateV0: quorum_sets=quorum_sets, tx_sets=tx_sets, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -100,29 +89,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PersistedSCPStateV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.scp_envelopes, - self.quorum_sets, - self.tx_sets, - ) - ) - + return hash((self.scp_envelopes, self.quorum_sets, self.tx_sets,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.scp_envelopes == other.scp_envelopes - and self.quorum_sets == other.quorum_sets - and self.tx_sets == other.tx_sets - ) - + return self.scp_envelopes== other.scp_envelopes and self.quorum_sets== other.quorum_sets and self.tx_sets== other.tx_sets def __str__(self): out = [ - f"scp_envelopes={self.scp_envelopes}", - f"quorum_sets={self.quorum_sets}", - f"tx_sets={self.tx_sets}", + f'scp_envelopes={self.scp_envelopes}', + f'quorum_sets={self.quorum_sets}', + f'tx_sets={self.tx_sets}', ] return f"" diff --git a/stellar_sdk/xdr/persisted_scp_state_v1.py b/stellar_sdk/xdr/persisted_scp_state_v1.py index 41a2f411..5200df99 100644 --- a/stellar_sdk/xdr/persisted_scp_state_v1.py +++ b/stellar_sdk/xdr/persisted_scp_state_v1.py @@ -3,28 +3,26 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .scp_envelope import SCPEnvelope from .scp_quorum_set import SCPQuorumSet - -__all__ = ["PersistedSCPStateV1"] - - +__all__ = ['PersistedSCPStateV1'] class PersistedSCPStateV1: """ XDR Source Code:: - struct PersistedSCPStateV1 - { - // Tx sets are saved separately - SCPEnvelope scpEnvelopes<>; - SCPQuorumSet quorumSets<>; - }; + struct PersistedSCPStateV1 + { + // Tx sets are saved separately + SCPEnvelope scpEnvelopes<>; + SCPQuorumSet quorumSets<>; + }; """ - def __init__( self, scp_envelopes: List[SCPEnvelope], @@ -32,17 +30,12 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if scp_envelopes and len(scp_envelopes) > _expect_max_length: - raise ValueError( - f"The maximum length of `scp_envelopes` should be {_expect_max_length}, but got {len(scp_envelopes)}." - ) + raise ValueError(f"The maximum length of `scp_envelopes` should be {_expect_max_length}, but got {len(scp_envelopes)}.") _expect_max_length = 4294967295 if quorum_sets and len(quorum_sets) > _expect_max_length: - raise ValueError( - f"The maximum length of `quorum_sets` should be {_expect_max_length}, but got {len(quorum_sets)}." - ) + raise ValueError(f"The maximum length of `quorum_sets` should be {_expect_max_length}, but got {len(quorum_sets)}.") self.scp_envelopes = scp_envelopes self.quorum_sets = quorum_sets - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.scp_envelopes)) for scp_envelopes_item in self.scp_envelopes: @@ -50,7 +43,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.quorum_sets)) for quorum_sets_item in self.quorum_sets: quorum_sets_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PersistedSCPStateV1: length = unpacker.unpack_uint() @@ -65,7 +57,6 @@ def unpack(cls, unpacker: Unpacker) -> PersistedSCPStateV1: scp_envelopes=scp_envelopes, quorum_sets=quorum_sets, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -84,26 +75,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PersistedSCPStateV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.scp_envelopes, - self.quorum_sets, - ) - ) - + return hash((self.scp_envelopes, self.quorum_sets,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.scp_envelopes == other.scp_envelopes - and self.quorum_sets == other.quorum_sets - ) - + return self.scp_envelopes== other.scp_envelopes and self.quorum_sets== other.quorum_sets def __str__(self): out = [ - f"scp_envelopes={self.scp_envelopes}", - f"quorum_sets={self.quorum_sets}", + f'scp_envelopes={self.scp_envelopes}', + f'quorum_sets={self.quorum_sets}', ] return f"" diff --git a/stellar_sdk/xdr/pool_id.py b/stellar_sdk/xdr/pool_id.py index 20986ca7..03661382 100644 --- a/stellar_sdk/xdr/pool_id.py +++ b/stellar_sdk/xdr/pool_id.py @@ -3,32 +3,28 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash - -__all__ = ["PoolID"] - - +__all__ = ['PoolID'] class PoolID: """ XDR Source Code:: typedef Hash PoolID; """ - def __init__(self, pool_id: Hash) -> None: self.pool_id = pool_id - def pack(self, packer: Packer) -> None: self.pool_id.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PoolID: pool_id = Hash.unpack(unpacker) return cls(pool_id) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +43,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PoolID: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.pool_id) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/precondition_type.py b/stellar_sdk/xdr/precondition_type.py index 187cde23..1287083f 100644 --- a/stellar_sdk/xdr/precondition_type.py +++ b/stellar_sdk/xdr/precondition_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["PreconditionType"] - - +__all__ = ['PreconditionType'] class PreconditionType(IntEnum): """ XDR Source Code:: @@ -21,11 +21,9 @@ class PreconditionType(IntEnum): PRECOND_V2 = 2 }; """ - PRECOND_NONE = 0 PRECOND_TIME = 1 PRECOND_V2 = 2 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -33,7 +31,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> PreconditionType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/preconditions.py b/stellar_sdk/xdr/preconditions.py index 26680152..c542ba6c 100644 --- a/stellar_sdk/xdr/preconditions.py +++ b/stellar_sdk/xdr/preconditions.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .precondition_type import PreconditionType -from .preconditions_v2 import PreconditionsV2 from .time_bounds import TimeBounds - -__all__ = ["Preconditions"] - - +from .preconditions_v2 import PreconditionsV2 +__all__ = ['Preconditions'] class Preconditions: """ XDR Source Code:: @@ -27,7 +27,6 @@ class Preconditions: PreconditionsV2 v2; }; """ - def __init__( self, type: PreconditionType, @@ -37,7 +36,6 @@ def __init__( self.type = type self.time_bounds = time_bounds self.v2 = v2 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == PreconditionType.PRECOND_NONE: @@ -52,7 +50,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v2 should not be None.") self.v2.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> Preconditions: type = PreconditionType.unpack(unpacker) @@ -65,7 +62,6 @@ def unpack(cls, unpacker: Unpacker) -> Preconditions: v2 = PreconditionsV2.unpack(unpacker) return cls(type=type, v2=v2) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -84,30 +80,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Preconditions: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.time_bounds, - self.v2, - ) - ) - + return hash((self.type, self.time_bounds, self.v2,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.time_bounds == other.time_bounds - and self.v2 == other.v2 - ) - + return self.type== other.type and self.time_bounds== other.time_bounds and self.v2== other.v2 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"time_bounds={self.time_bounds}" - ) if self.time_bounds is not None else None - out.append(f"v2={self.v2}") if self.v2 is not None else None + out.append(f'type={self.type}') + out.append(f'time_bounds={self.time_bounds}') if self.time_bounds is not None else None + out.append(f'v2={self.v2}') if self.v2 is not None else None return f"" diff --git a/stellar_sdk/xdr/preconditions_v2.py b/stellar_sdk/xdr/preconditions_v2.py index 04a17b33..64044d7d 100644 --- a/stellar_sdk/xdr/preconditions_v2.py +++ b/stellar_sdk/xdr/preconditions_v2.py @@ -3,20 +3,19 @@ from __future__ import annotations import base64 -from typing import List, Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .duration import Duration +from .time_bounds import TimeBounds from .ledger_bounds import LedgerBounds from .sequence_number import SequenceNumber -from .signer_key import SignerKey -from .time_bounds import TimeBounds +from .duration import Duration from .uint32 import Uint32 - -__all__ = ["PreconditionsV2"] - - +from .signer_key import SignerKey +__all__ = ['PreconditionsV2'] class PreconditionsV2: """ XDR Source Code:: @@ -54,7 +53,6 @@ class PreconditionsV2: SignerKey extraSigners<2>; }; """ - def __init__( self, time_bounds: Optional[TimeBounds], @@ -66,16 +64,13 @@ def __init__( ) -> None: _expect_max_length = 2 if extra_signers and len(extra_signers) > _expect_max_length: - raise ValueError( - f"The maximum length of `extra_signers` should be {_expect_max_length}, but got {len(extra_signers)}." - ) + raise ValueError(f"The maximum length of `extra_signers` should be {_expect_max_length}, but got {len(extra_signers)}.") self.time_bounds = time_bounds self.ledger_bounds = ledger_bounds self.min_seq_num = min_seq_num self.min_seq_age = min_seq_age self.min_seq_ledger_gap = min_seq_ledger_gap self.extra_signers = extra_signers - def pack(self, packer: Packer) -> None: if self.time_bounds is None: packer.pack_uint(0) @@ -97,16 +92,11 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.extra_signers)) for extra_signers_item in self.extra_signers: extra_signers_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> PreconditionsV2: time_bounds = TimeBounds.unpack(unpacker) if unpacker.unpack_uint() else None - ledger_bounds = ( - LedgerBounds.unpack(unpacker) if unpacker.unpack_uint() else None - ) - min_seq_num = ( - SequenceNumber.unpack(unpacker) if unpacker.unpack_uint() else None - ) + ledger_bounds = LedgerBounds.unpack(unpacker) if unpacker.unpack_uint() else None + min_seq_num = SequenceNumber.unpack(unpacker) if unpacker.unpack_uint() else None min_seq_age = Duration.unpack(unpacker) min_seq_ledger_gap = Uint32.unpack(unpacker) length = unpacker.unpack_uint() @@ -121,7 +111,6 @@ def unpack(cls, unpacker: Unpacker) -> PreconditionsV2: min_seq_ledger_gap=min_seq_ledger_gap, extra_signers=extra_signers, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -140,38 +129,19 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PreconditionsV2: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.time_bounds, - self.ledger_bounds, - self.min_seq_num, - self.min_seq_age, - self.min_seq_ledger_gap, - self.extra_signers, - ) - ) - + return hash((self.time_bounds, self.ledger_bounds, self.min_seq_num, self.min_seq_age, self.min_seq_ledger_gap, self.extra_signers,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.time_bounds == other.time_bounds - and self.ledger_bounds == other.ledger_bounds - and self.min_seq_num == other.min_seq_num - and self.min_seq_age == other.min_seq_age - and self.min_seq_ledger_gap == other.min_seq_ledger_gap - and self.extra_signers == other.extra_signers - ) - + return self.time_bounds== other.time_bounds and self.ledger_bounds== other.ledger_bounds and self.min_seq_num== other.min_seq_num and self.min_seq_age== other.min_seq_age and self.min_seq_ledger_gap== other.min_seq_ledger_gap and self.extra_signers== other.extra_signers def __str__(self): out = [ - f"time_bounds={self.time_bounds}", - f"ledger_bounds={self.ledger_bounds}", - f"min_seq_num={self.min_seq_num}", - f"min_seq_age={self.min_seq_age}", - f"min_seq_ledger_gap={self.min_seq_ledger_gap}", - f"extra_signers={self.extra_signers}", + f'time_bounds={self.time_bounds}', + f'ledger_bounds={self.ledger_bounds}', + f'min_seq_num={self.min_seq_num}', + f'min_seq_age={self.min_seq_age}', + f'min_seq_ledger_gap={self.min_seq_ledger_gap}', + f'extra_signers={self.extra_signers}', ] return f"" diff --git a/stellar_sdk/xdr/price.py b/stellar_sdk/xdr/price.py index a1a478bc..cccffc2a 100644 --- a/stellar_sdk/xdr/price.py +++ b/stellar_sdk/xdr/price.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int32 import Int32 - -__all__ = ["Price"] - - +from .int32 import Int32 +__all__ = ['Price'] class Price: """ XDR Source Code:: @@ -21,7 +22,6 @@ class Price: int32 d; // denominator }; """ - def __init__( self, n: Int32, @@ -29,11 +29,9 @@ def __init__( ) -> None: self.n = n self.d = d - def pack(self, packer: Packer) -> None: self.n.pack(packer) self.d.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Price: n = Int32.unpack(unpacker) @@ -42,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> Price: n=n, d=d, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Price: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.n, - self.d, - ) - ) - + return hash((self.n, self.d,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.n == other.n and self.d == other.d - + return self.n== other.n and self.d== other.d def __str__(self): out = [ - f"n={self.n}", - f"d={self.d}", + f'n={self.n}', + f'd={self.d}', ] return f"" diff --git a/stellar_sdk/xdr/public_key.py b/stellar_sdk/xdr/public_key.py index 621a66d0..513446b3 100644 --- a/stellar_sdk/xdr/public_key.py +++ b/stellar_sdk/xdr/public_key.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .public_key_type import PublicKeyType from .uint256 import Uint256 - -__all__ = ["PublicKey"] - - +__all__ = ['PublicKey'] class PublicKey: """ XDR Source Code:: @@ -22,7 +22,6 @@ class PublicKey: uint256 ed25519; }; """ - def __init__( self, type: PublicKeyType, @@ -30,7 +29,6 @@ def __init__( ) -> None: self.type = type self.ed25519 = ed25519 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == PublicKeyType.PUBLIC_KEY_TYPE_ED25519: @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("ed25519 should not be None.") self.ed25519.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> PublicKey: type = PublicKeyType.unpack(unpacker) @@ -46,7 +43,6 @@ def unpack(cls, unpacker: Unpacker) -> PublicKey: ed25519 = Uint256.unpack(unpacker) return cls(type=type, ed25519=ed25519) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -65,22 +61,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> PublicKey: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.ed25519, - ) - ) - + return hash((self.type, self.ed25519,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.type == other.type and self.ed25519 == other.ed25519 - + return self.type== other.type and self.ed25519== other.ed25519 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"ed25519={self.ed25519}") if self.ed25519 is not None else None + out.append(f'type={self.type}') + out.append(f'ed25519={self.ed25519}') if self.ed25519 is not None else None return f"" diff --git a/stellar_sdk/xdr/public_key_type.py b/stellar_sdk/xdr/public_key_type.py index 35230df8..8a851810 100644 --- a/stellar_sdk/xdr/public_key_type.py +++ b/stellar_sdk/xdr/public_key_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["PublicKeyType"] - - +__all__ = ['PublicKeyType'] class PublicKeyType(IntEnum): """ XDR Source Code:: @@ -19,9 +19,7 @@ class PublicKeyType(IntEnum): PUBLIC_KEY_TYPE_ED25519 = KEY_TYPE_ED25519 }; """ - PUBLIC_KEY_TYPE_ED25519 = 0 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -29,7 +27,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> PublicKeyType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/restore_footprint_op.py b/stellar_sdk/xdr/restore_footprint_op.py index 6b20bc7a..aef552e5 100644 --- a/stellar_sdk/xdr/restore_footprint_op.py +++ b/stellar_sdk/xdr/restore_footprint_op.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .extension_point import ExtensionPoint - -__all__ = ["RestoreFootprintOp"] - - +__all__ = ['RestoreFootprintOp'] class RestoreFootprintOp: """ XDR Source Code:: @@ -20,23 +20,19 @@ class RestoreFootprintOp: ExtensionPoint ext; }; """ - def __init__( self, ext: ExtensionPoint, ) -> None: self.ext = ext - def pack(self, packer: Packer) -> None: self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> RestoreFootprintOp: ext = ExtensionPoint.unpack(unpacker) return cls( ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> RestoreFootprintOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.ext,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.ext == other.ext - + return self.ext== other.ext def __str__(self): out = [ - f"ext={self.ext}", + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/restore_footprint_result.py b/stellar_sdk/xdr/restore_footprint_result.py index 4ba6c7ae..1b3aff46 100644 --- a/stellar_sdk/xdr/restore_footprint_result.py +++ b/stellar_sdk/xdr/restore_footprint_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .restore_footprint_result_code import RestoreFootprintResultCode - -__all__ = ["RestoreFootprintResult"] - - +__all__ = ['RestoreFootprintResult'] class RestoreFootprintResult: """ XDR Source Code:: @@ -25,30 +25,21 @@ class RestoreFootprintResult: void; }; """ - def __init__( self, code: RestoreFootprintResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == RestoreFootprintResultCode.RESTORE_FOOTPRINT_SUCCESS: return if self.code == RestoreFootprintResultCode.RESTORE_FOOTPRINT_MALFORMED: return - if ( - self.code - == RestoreFootprintResultCode.RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED - ): + if self.code == RestoreFootprintResultCode.RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED: return - if ( - self.code - == RestoreFootprintResultCode.RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE - ): + if self.code == RestoreFootprintResultCode.RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE: return - @classmethod def unpack(cls, unpacker: Unpacker) -> RestoreFootprintResult: code = RestoreFootprintResultCode.unpack(unpacker) @@ -58,13 +49,9 @@ def unpack(cls, unpacker: Unpacker) -> RestoreFootprintResult: return cls(code=code) if code == RestoreFootprintResultCode.RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED: return cls(code=code) - if ( - code - == RestoreFootprintResultCode.RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE - ): + if code == RestoreFootprintResultCode.RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -83,16 +70,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> RestoreFootprintResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/restore_footprint_result_code.py b/stellar_sdk/xdr/restore_footprint_result_code.py index 783e14e8..c83a53b5 100644 --- a/stellar_sdk/xdr/restore_footprint_result_code.py +++ b/stellar_sdk/xdr/restore_footprint_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["RestoreFootprintResultCode"] - - +__all__ = ['RestoreFootprintResultCode'] class RestoreFootprintResultCode(IntEnum): """ XDR Source Code:: @@ -25,12 +25,10 @@ class RestoreFootprintResultCode(IntEnum): RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE = -3 }; """ - RESTORE_FOOTPRINT_SUCCESS = 0 RESTORE_FOOTPRINT_MALFORMED = -1 RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED = -2 RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE = -3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> RestoreFootprintResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/revoke_sponsorship_op.py b/stellar_sdk/xdr/revoke_sponsorship_op.py index b1114938..0b628382 100644 --- a/stellar_sdk/xdr/revoke_sponsorship_op.py +++ b/stellar_sdk/xdr/revoke_sponsorship_op.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .revoke_sponsorship_type import RevokeSponsorshipType from .ledger_key import LedgerKey from .revoke_sponsorship_op_signer import RevokeSponsorshipOpSigner -from .revoke_sponsorship_type import RevokeSponsorshipType - -__all__ = ["RevokeSponsorshipOp"] - - +__all__ = ['RevokeSponsorshipOp'] class RevokeSponsorshipOp: """ XDR Source Code:: @@ -29,7 +29,6 @@ class RevokeSponsorshipOp: } signer; }; """ - def __init__( self, type: RevokeSponsorshipType, @@ -39,7 +38,6 @@ def __init__( self.type = type self.ledger_key = ledger_key self.signer = signer - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == RevokeSponsorshipType.REVOKE_SPONSORSHIP_LEDGER_ENTRY: @@ -52,7 +50,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("signer should not be None.") self.signer.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> RevokeSponsorshipOp: type = RevokeSponsorshipType.unpack(unpacker) @@ -63,7 +60,6 @@ def unpack(cls, unpacker: Unpacker) -> RevokeSponsorshipOp: signer = RevokeSponsorshipOpSigner.unpack(unpacker) return cls(type=type, signer=signer) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -82,30 +78,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> RevokeSponsorshipOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.ledger_key, - self.signer, - ) - ) - + return hash((self.type, self.ledger_key, self.signer,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.ledger_key == other.ledger_key - and self.signer == other.signer - ) - + return self.type== other.type and self.ledger_key== other.ledger_key and self.signer== other.signer def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"ledger_key={self.ledger_key}" - ) if self.ledger_key is not None else None - out.append(f"signer={self.signer}") if self.signer is not None else None + out.append(f'type={self.type}') + out.append(f'ledger_key={self.ledger_key}') if self.ledger_key is not None else None + out.append(f'signer={self.signer}') if self.signer is not None else None return f"" diff --git a/stellar_sdk/xdr/revoke_sponsorship_op_signer.py b/stellar_sdk/xdr/revoke_sponsorship_op_signer.py index a9a8996d..8c746c58 100644 --- a/stellar_sdk/xdr/revoke_sponsorship_op_signer.py +++ b/stellar_sdk/xdr/revoke_sponsorship_op_signer.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .signer_key import SignerKey - -__all__ = ["RevokeSponsorshipOpSigner"] - - +__all__ = ['RevokeSponsorshipOpSigner'] class RevokeSponsorshipOpSigner: """ XDR Source Code:: @@ -22,7 +22,6 @@ class RevokeSponsorshipOpSigner: SignerKey signerKey; } """ - def __init__( self, account_id: AccountID, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.account_id = account_id self.signer_key = signer_key - def pack(self, packer: Packer) -> None: self.account_id.pack(packer) self.signer_key.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> RevokeSponsorshipOpSigner: account_id = AccountID.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> RevokeSponsorshipOpSigner: account_id=account_id, signer_key=signer_key, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,25 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> RevokeSponsorshipOpSigner: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.account_id, - self.signer_key, - ) - ) - + return hash((self.account_id, self.signer_key,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.account_id == other.account_id and self.signer_key == other.signer_key - ) - + return self.account_id== other.account_id and self.signer_key== other.signer_key def __str__(self): out = [ - f"account_id={self.account_id}", - f"signer_key={self.signer_key}", + f'account_id={self.account_id}', + f'signer_key={self.signer_key}', ] return f"" diff --git a/stellar_sdk/xdr/revoke_sponsorship_result.py b/stellar_sdk/xdr/revoke_sponsorship_result.py index 8cf6ac77..15801dc0 100644 --- a/stellar_sdk/xdr/revoke_sponsorship_result.py +++ b/stellar_sdk/xdr/revoke_sponsorship_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .revoke_sponsorship_result_code import RevokeSponsorshipResultCode - -__all__ = ["RevokeSponsorshipResult"] - - +__all__ = ['RevokeSponsorshipResult'] class RevokeSponsorshipResult: """ XDR Source Code:: @@ -27,13 +27,11 @@ class RevokeSponsorshipResult: void; }; """ - def __init__( self, code: RevokeSponsorshipResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == RevokeSponsorshipResultCode.REVOKE_SPONSORSHIP_SUCCESS: @@ -44,14 +42,10 @@ def pack(self, packer: Packer) -> None: return if self.code == RevokeSponsorshipResultCode.REVOKE_SPONSORSHIP_LOW_RESERVE: return - if ( - self.code - == RevokeSponsorshipResultCode.REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE - ): + if self.code == RevokeSponsorshipResultCode.REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE: return if self.code == RevokeSponsorshipResultCode.REVOKE_SPONSORSHIP_MALFORMED: return - @classmethod def unpack(cls, unpacker: Unpacker) -> RevokeSponsorshipResult: code = RevokeSponsorshipResultCode.unpack(unpacker) @@ -68,7 +62,6 @@ def unpack(cls, unpacker: Unpacker) -> RevokeSponsorshipResult: if code == RevokeSponsorshipResultCode.REVOKE_SPONSORSHIP_MALFORMED: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -87,16 +80,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> RevokeSponsorshipResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/revoke_sponsorship_result_code.py b/stellar_sdk/xdr/revoke_sponsorship_result_code.py index 73657695..6c8afe23 100644 --- a/stellar_sdk/xdr/revoke_sponsorship_result_code.py +++ b/stellar_sdk/xdr/revoke_sponsorship_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["RevokeSponsorshipResultCode"] - - +__all__ = ['RevokeSponsorshipResultCode'] class RevokeSponsorshipResultCode(IntEnum): """ XDR Source Code:: @@ -27,14 +27,12 @@ class RevokeSponsorshipResultCode(IntEnum): REVOKE_SPONSORSHIP_MALFORMED = -5 }; """ - REVOKE_SPONSORSHIP_SUCCESS = 0 REVOKE_SPONSORSHIP_DOES_NOT_EXIST = -1 REVOKE_SPONSORSHIP_NOT_SPONSOR = -2 REVOKE_SPONSORSHIP_LOW_RESERVE = -3 REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE = -4 REVOKE_SPONSORSHIP_MALFORMED = -5 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -42,7 +40,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> RevokeSponsorshipResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/revoke_sponsorship_type.py b/stellar_sdk/xdr/revoke_sponsorship_type.py index f4f16b72..a5aec88c 100644 --- a/stellar_sdk/xdr/revoke_sponsorship_type.py +++ b/stellar_sdk/xdr/revoke_sponsorship_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["RevokeSponsorshipType"] - - +__all__ = ['RevokeSponsorshipType'] class RevokeSponsorshipType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class RevokeSponsorshipType(IntEnum): REVOKE_SPONSORSHIP_SIGNER = 1 }; """ - REVOKE_SPONSORSHIP_LEDGER_ENTRY = 0 REVOKE_SPONSORSHIP_SIGNER = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> RevokeSponsorshipType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_address.py b/stellar_sdk/xdr/sc_address.py index 6008e956..3a99c678 100644 --- a/stellar_sdk/xdr/sc_address.py +++ b/stellar_sdk/xdr/sc_address.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .sc_address_type import SCAddressType from .account_id import AccountID from .hash import Hash -from .sc_address_type import SCAddressType - -__all__ = ["SCAddress"] - - +__all__ = ['SCAddress'] class SCAddress: """ XDR Source Code:: @@ -25,7 +25,6 @@ class SCAddress: Hash contractId; }; """ - def __init__( self, type: SCAddressType, @@ -35,7 +34,6 @@ def __init__( self.type = type self.account_id = account_id self.contract_id = contract_id - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == SCAddressType.SC_ADDRESS_TYPE_ACCOUNT: @@ -48,7 +46,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("contract_id should not be None.") self.contract_id.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCAddress: type = SCAddressType.unpack(unpacker) @@ -59,7 +56,6 @@ def unpack(cls, unpacker: Unpacker) -> SCAddress: contract_id = Hash.unpack(unpacker) return cls(type=type, contract_id=contract_id) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -78,32 +74,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCAddress: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.account_id, - self.contract_id, - ) - ) - + return hash((self.type, self.account_id, self.contract_id,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.account_id == other.account_id - and self.contract_id == other.contract_id - ) - + return self.type== other.type and self.account_id== other.account_id and self.contract_id== other.contract_id def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"account_id={self.account_id}" - ) if self.account_id is not None else None - out.append( - f"contract_id={self.contract_id}" - ) if self.contract_id is not None else None + out.append(f'type={self.type}') + out.append(f'account_id={self.account_id}') if self.account_id is not None else None + out.append(f'contract_id={self.contract_id}') if self.contract_id is not None else None return f"" diff --git a/stellar_sdk/xdr/sc_address_type.py b/stellar_sdk/xdr/sc_address_type.py index d210541a..b30e6f21 100644 --- a/stellar_sdk/xdr/sc_address_type.py +++ b/stellar_sdk/xdr/sc_address_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCAddressType"] - - +__all__ = ['SCAddressType'] class SCAddressType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class SCAddressType(IntEnum): SC_ADDRESS_TYPE_CONTRACT = 1 }; """ - SC_ADDRESS_TYPE_ACCOUNT = 0 SC_ADDRESS_TYPE_CONTRACT = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCAddressType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_bytes.py b/stellar_sdk/xdr/sc_bytes.py index ea12b406..172a70f9 100644 --- a/stellar_sdk/xdr/sc_bytes.py +++ b/stellar_sdk/xdr/sc_bytes.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["SCBytes"] - - +__all__ = ['SCBytes'] class SCBytes: """ XDR Source Code:: typedef opaque SCBytes<>; """ - def __init__(self, sc_bytes: bytes) -> None: self.sc_bytes = sc_bytes - def pack(self, packer: Packer) -> None: Opaque(self.sc_bytes, 4294967295, False).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCBytes: sc_bytes = Opaque.unpack(unpacker, 4294967295, False) return cls(sc_bytes) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCBytes: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.sc_bytes) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/sc_contract_instance.py b/stellar_sdk/xdr/sc_contract_instance.py index 13f61960..7f82e6ee 100644 --- a/stellar_sdk/xdr/sc_contract_instance.py +++ b/stellar_sdk/xdr/sc_contract_instance.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .contract_executable import ContractExecutable from .sc_map import SCMap - -__all__ = ["SCContractInstance"] - - +__all__ = ['SCContractInstance'] class SCContractInstance: """ XDR Source Code:: @@ -22,7 +21,6 @@ class SCContractInstance: SCMap* storage; }; """ - def __init__( self, executable: ContractExecutable, @@ -30,7 +28,6 @@ def __init__( ) -> None: self.executable = executable self.storage = storage - def pack(self, packer: Packer) -> None: self.executable.pack(packer) if self.storage is None: @@ -38,7 +35,6 @@ def pack(self, packer: Packer) -> None: else: packer.pack_uint(1) self.storage.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCContractInstance: executable = ContractExecutable.unpack(unpacker) @@ -47,7 +43,6 @@ def unpack(cls, unpacker: Unpacker) -> SCContractInstance: executable=executable, storage=storage, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -66,23 +61,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCContractInstance: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.executable, - self.storage, - ) - ) - + return hash((self.executable, self.storage,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.executable == other.executable and self.storage == other.storage - + return self.executable== other.executable and self.storage== other.storage def __str__(self): out = [ - f"executable={self.executable}", - f"storage={self.storage}", + f'executable={self.executable}', + f'storage={self.storage}', ] return f"" diff --git a/stellar_sdk/xdr/sc_env_meta_entry.py b/stellar_sdk/xdr/sc_env_meta_entry.py index 77c98e09..307c1363 100644 --- a/stellar_sdk/xdr/sc_env_meta_entry.py +++ b/stellar_sdk/xdr/sc_env_meta_entry.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_env_meta_kind import SCEnvMetaKind from .uint64 import Uint64 - -__all__ = ["SCEnvMetaEntry"] - - +__all__ = ['SCEnvMetaEntry'] class SCEnvMetaEntry: """ XDR Source Code:: @@ -22,7 +22,6 @@ class SCEnvMetaEntry: uint64 interfaceVersion; }; """ - def __init__( self, kind: SCEnvMetaKind, @@ -30,7 +29,6 @@ def __init__( ) -> None: self.kind = kind self.interface_version = interface_version - def pack(self, packer: Packer) -> None: self.kind.pack(packer) if self.kind == SCEnvMetaKind.SC_ENV_META_KIND_INTERFACE_VERSION: @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("interface_version should not be None.") self.interface_version.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCEnvMetaEntry: kind = SCEnvMetaKind.unpack(unpacker) @@ -46,7 +43,6 @@ def unpack(cls, unpacker: Unpacker) -> SCEnvMetaEntry: interface_version = Uint64.unpack(unpacker) return cls(kind=kind, interface_version=interface_version) return cls(kind=kind) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -65,27 +61,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCEnvMetaEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.kind, - self.interface_version, - ) - ) - + return hash((self.kind, self.interface_version,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.kind == other.kind - and self.interface_version == other.interface_version - ) - + return self.kind== other.kind and self.interface_version== other.interface_version def __str__(self): out = [] - out.append(f"kind={self.kind}") - out.append( - f"interface_version={self.interface_version}" - ) if self.interface_version is not None else None + out.append(f'kind={self.kind}') + out.append(f'interface_version={self.interface_version}') if self.interface_version is not None else None return f"" diff --git a/stellar_sdk/xdr/sc_env_meta_kind.py b/stellar_sdk/xdr/sc_env_meta_kind.py index d6053639..d809720e 100644 --- a/stellar_sdk/xdr/sc_env_meta_kind.py +++ b/stellar_sdk/xdr/sc_env_meta_kind.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCEnvMetaKind"] - - +__all__ = ['SCEnvMetaKind'] class SCEnvMetaKind(IntEnum): """ XDR Source Code:: @@ -19,9 +19,7 @@ class SCEnvMetaKind(IntEnum): SC_ENV_META_KIND_INTERFACE_VERSION = 0 }; """ - SC_ENV_META_KIND_INTERFACE_VERSION = 0 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -29,7 +27,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCEnvMetaKind: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_error.py b/stellar_sdk/xdr/sc_error.py index f8d6b8d7..df8ecd6b 100644 --- a/stellar_sdk/xdr/sc_error.py +++ b/stellar_sdk/xdr/sc_error.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .sc_error_code import SCErrorCode from .sc_error_type import SCErrorType from .uint32 import Uint32 - -__all__ = ["SCError"] - - +from .sc_error_code import SCErrorCode +__all__ = ['SCError'] class SCError: """ XDR Source Code:: @@ -33,7 +33,6 @@ class SCError: SCErrorCode code; }; """ - def __init__( self, type: SCErrorType, @@ -43,7 +42,6 @@ def __init__( self.type = type self.contract_code = contract_code self.code = code - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == SCErrorType.SCE_CONTRACT: @@ -96,7 +94,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("code should not be None.") self.code.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCError: type = SCErrorType.unpack(unpacker) @@ -131,7 +128,6 @@ def unpack(cls, unpacker: Unpacker) -> SCError: code = SCErrorCode.unpack(unpacker) return cls(type=type, code=code) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -150,30 +146,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCError: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.contract_code, - self.code, - ) - ) - + return hash((self.type, self.contract_code, self.code,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.contract_code == other.contract_code - and self.code == other.code - ) - + return self.type== other.type and self.contract_code== other.contract_code and self.code== other.code def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"contract_code={self.contract_code}" - ) if self.contract_code is not None else None - out.append(f"code={self.code}") if self.code is not None else None + out.append(f'type={self.type}') + out.append(f'contract_code={self.contract_code}') if self.contract_code is not None else None + out.append(f'code={self.code}') if self.code is not None else None return f"" diff --git a/stellar_sdk/xdr/sc_error_code.py b/stellar_sdk/xdr/sc_error_code.py index d2593af1..ae009072 100644 --- a/stellar_sdk/xdr/sc_error_code.py +++ b/stellar_sdk/xdr/sc_error_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCErrorCode"] - - +__all__ = ['SCErrorCode'] class SCErrorCode(IntEnum): """ XDR Source Code:: @@ -28,7 +28,6 @@ class SCErrorCode(IntEnum): SCEC_UNEXPECTED_SIZE = 9 // Something's size wasn't as expected. }; """ - SCEC_ARITH_DOMAIN = 0 SCEC_INDEX_BOUNDS = 1 SCEC_INVALID_INPUT = 2 @@ -39,7 +38,6 @@ class SCErrorCode(IntEnum): SCEC_INTERNAL_ERROR = 7 SCEC_UNEXPECTED_TYPE = 8 SCEC_UNEXPECTED_SIZE = 9 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -47,7 +45,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCErrorCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_error_type.py b/stellar_sdk/xdr/sc_error_type.py index e1016eb0..d0bbd418 100644 --- a/stellar_sdk/xdr/sc_error_type.py +++ b/stellar_sdk/xdr/sc_error_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCErrorType"] - - +__all__ = ['SCErrorType'] class SCErrorType(IntEnum): """ XDR Source Code:: @@ -28,7 +28,6 @@ class SCErrorType(IntEnum): SCE_AUTH = 9 // Errors from the authentication subsystem. }; """ - SCE_CONTRACT = 0 SCE_WASM_VM = 1 SCE_CONTEXT = 2 @@ -39,7 +38,6 @@ class SCErrorType(IntEnum): SCE_BUDGET = 7 SCE_VALUE = 8 SCE_AUTH = 9 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -47,7 +45,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCErrorType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_map.py b/stellar_sdk/xdr/sc_map.py index bae37e96..c3caea3f 100644 --- a/stellar_sdk/xdr/sc_map.py +++ b/stellar_sdk/xdr/sc_map.py @@ -3,35 +3,29 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_map_entry import SCMapEntry - -__all__ = ["SCMap"] - - +__all__ = ['SCMap'] class SCMap: """ XDR Source Code:: typedef SCMapEntry SCMap<>; """ - def __init__(self, sc_map: List[SCMapEntry]) -> None: _expect_max_length = 4294967295 if sc_map and len(sc_map) > _expect_max_length: - raise ValueError( - f"The maximum length of `sc_map` should be {_expect_max_length}, but got {len(sc_map)}." - ) + raise ValueError(f"The maximum length of `sc_map` should be {_expect_max_length}, but got {len(sc_map)}.") self.sc_map = sc_map - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.sc_map)) for sc_map_item in self.sc_map: sc_map_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCMap: length = unpacker.unpack_uint() @@ -39,7 +33,6 @@ def unpack(cls, unpacker: Unpacker) -> SCMap: for _ in range(length): sc_map.append(SCMapEntry.unpack(unpacker)) return cls(sc_map) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,10 +51,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCMap: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.sc_map) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/sc_map_entry.py b/stellar_sdk/xdr/sc_map_entry.py index d8fb15ae..48011ce6 100644 --- a/stellar_sdk/xdr/sc_map_entry.py +++ b/stellar_sdk/xdr/sc_map_entry.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_val import SCVal - -__all__ = ["SCMapEntry"] - - +from .sc_val import SCVal +__all__ = ['SCMapEntry'] class SCMapEntry: """ XDR Source Code:: @@ -21,7 +22,6 @@ class SCMapEntry: SCVal val; }; """ - def __init__( self, key: SCVal, @@ -29,11 +29,9 @@ def __init__( ) -> None: self.key = key self.val = val - def pack(self, packer: Packer) -> None: self.key.pack(packer) self.val.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCMapEntry: key = SCVal.unpack(unpacker) @@ -42,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SCMapEntry: key=key, val=val, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCMapEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.key, - self.val, - ) - ) - + return hash((self.key, self.val,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.key == other.key and self.val == other.val - + return self.key== other.key and self.val== other.val def __str__(self): out = [ - f"key={self.key}", - f"val={self.val}", + f'key={self.key}', + f'val={self.val}', ] return f"" diff --git a/stellar_sdk/xdr/sc_meta_entry.py b/stellar_sdk/xdr/sc_meta_entry.py index b79182bc..8bd25264 100644 --- a/stellar_sdk/xdr/sc_meta_entry.py +++ b/stellar_sdk/xdr/sc_meta_entry.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_meta_kind import SCMetaKind from .sc_meta_v0 import SCMetaV0 - -__all__ = ["SCMetaEntry"] - - +__all__ = ['SCMetaEntry'] class SCMetaEntry: """ XDR Source Code:: @@ -22,7 +22,6 @@ class SCMetaEntry: SCMetaV0 v0; }; """ - def __init__( self, kind: SCMetaKind, @@ -30,7 +29,6 @@ def __init__( ) -> None: self.kind = kind self.v0 = v0 - def pack(self, packer: Packer) -> None: self.kind.pack(packer) if self.kind == SCMetaKind.SC_META_V0: @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v0 should not be None.") self.v0.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCMetaEntry: kind = SCMetaKind.unpack(unpacker) @@ -46,7 +43,6 @@ def unpack(cls, unpacker: Unpacker) -> SCMetaEntry: v0 = SCMetaV0.unpack(unpacker) return cls(kind=kind, v0=v0) return cls(kind=kind) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -65,22 +61,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCMetaEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.kind, - self.v0, - ) - ) - + return hash((self.kind, self.v0,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.kind == other.kind and self.v0 == other.v0 - + return self.kind== other.kind and self.v0== other.v0 def __str__(self): out = [] - out.append(f"kind={self.kind}") - out.append(f"v0={self.v0}") if self.v0 is not None else None + out.append(f'kind={self.kind}') + out.append(f'v0={self.v0}') if self.v0 is not None else None return f"" diff --git a/stellar_sdk/xdr/sc_meta_kind.py b/stellar_sdk/xdr/sc_meta_kind.py index 41e1a931..77844674 100644 --- a/stellar_sdk/xdr/sc_meta_kind.py +++ b/stellar_sdk/xdr/sc_meta_kind.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCMetaKind"] - - +__all__ = ['SCMetaKind'] class SCMetaKind(IntEnum): """ XDR Source Code:: @@ -19,9 +19,7 @@ class SCMetaKind(IntEnum): SC_META_V0 = 0 }; """ - SC_META_V0 = 0 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -29,7 +27,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCMetaKind: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_meta_v0.py b/stellar_sdk/xdr/sc_meta_v0.py index ed1a9e49..f38dd238 100644 --- a/stellar_sdk/xdr/sc_meta_v0.py +++ b/stellar_sdk/xdr/sc_meta_v0.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import String - -__all__ = ["SCMetaV0"] - - +__all__ = ['SCMetaV0'] class SCMetaV0: """ XDR Source Code:: @@ -21,7 +20,6 @@ class SCMetaV0: string val<>; }; """ - def __init__( self, key: bytes, @@ -29,11 +27,9 @@ def __init__( ) -> None: self.key = key self.val = val - def pack(self, packer: Packer) -> None: String(self.key, 4294967295).pack(packer) String(self.val, 4294967295).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCMetaV0: key = String.unpack(unpacker) @@ -42,7 +38,6 @@ def unpack(cls, unpacker: Unpacker) -> SCMetaV0: key=key, val=val, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,23 +56,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCMetaV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.key, - self.val, - ) - ) - + return hash((self.key, self.val,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.key == other.key and self.val == other.val - + return self.key== other.key and self.val== other.val def __str__(self): out = [ - f"key={self.key}", - f"val={self.val}", + f'key={self.key}', + f'val={self.val}', ] return f"" diff --git a/stellar_sdk/xdr/sc_nonce_key.py b/stellar_sdk/xdr/sc_nonce_key.py index da3ca6ac..9ad5fa51 100644 --- a/stellar_sdk/xdr/sc_nonce_key.py +++ b/stellar_sdk/xdr/sc_nonce_key.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int64 import Int64 - -__all__ = ["SCNonceKey"] - - +__all__ = ['SCNonceKey'] class SCNonceKey: """ XDR Source Code:: @@ -19,23 +19,19 @@ class SCNonceKey: int64 nonce; }; """ - def __init__( self, nonce: Int64, ) -> None: self.nonce = nonce - def pack(self, packer: Packer) -> None: self.nonce.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCNonceKey: nonce = Int64.unpack(unpacker) return cls( nonce=nonce, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -54,17 +50,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCNonceKey: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.nonce,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.nonce == other.nonce - + return self.nonce== other.nonce def __str__(self): out = [ - f"nonce={self.nonce}", + f'nonce={self.nonce}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_entry.py b/stellar_sdk/xdr/sc_spec_entry.py index cc63cd83..fc314710 100644 --- a/stellar_sdk/xdr/sc_spec_entry.py +++ b/stellar_sdk/xdr/sc_spec_entry.py @@ -3,19 +3,19 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_spec_entry_kind import SCSpecEntryKind from .sc_spec_function_v0 import SCSpecFunctionV0 -from .sc_spec_udt_enum_v0 import SCSpecUDTEnumV0 -from .sc_spec_udt_error_enum_v0 import SCSpecUDTErrorEnumV0 from .sc_spec_udt_struct_v0 import SCSpecUDTStructV0 from .sc_spec_udt_union_v0 import SCSpecUDTUnionV0 - -__all__ = ["SCSpecEntry"] - - +from .sc_spec_udt_enum_v0 import SCSpecUDTEnumV0 +from .sc_spec_udt_error_enum_v0 import SCSpecUDTErrorEnumV0 +__all__ = ['SCSpecEntry'] class SCSpecEntry: """ XDR Source Code:: @@ -34,7 +34,6 @@ class SCSpecEntry: SCSpecUDTErrorEnumV0 udtErrorEnumV0; }; """ - def __init__( self, kind: SCSpecEntryKind, @@ -50,7 +49,6 @@ def __init__( self.udt_union_v0 = udt_union_v0 self.udt_enum_v0 = udt_enum_v0 self.udt_error_enum_v0 = udt_error_enum_v0 - def pack(self, packer: Packer) -> None: self.kind.pack(packer) if self.kind == SCSpecEntryKind.SC_SPEC_ENTRY_FUNCTION_V0: @@ -78,7 +76,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("udt_error_enum_v0 should not be None.") self.udt_error_enum_v0.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecEntry: kind = SCSpecEntryKind.unpack(unpacker) @@ -98,7 +95,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecEntry: udt_error_enum_v0 = SCSpecUDTErrorEnumV0.unpack(unpacker) return cls(kind=kind, udt_error_enum_v0=udt_error_enum_v0) return cls(kind=kind) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -117,47 +113,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.kind, - self.function_v0, - self.udt_struct_v0, - self.udt_union_v0, - self.udt_enum_v0, - self.udt_error_enum_v0, - ) - ) - + return hash((self.kind, self.function_v0, self.udt_struct_v0, self.udt_union_v0, self.udt_enum_v0, self.udt_error_enum_v0,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.kind == other.kind - and self.function_v0 == other.function_v0 - and self.udt_struct_v0 == other.udt_struct_v0 - and self.udt_union_v0 == other.udt_union_v0 - and self.udt_enum_v0 == other.udt_enum_v0 - and self.udt_error_enum_v0 == other.udt_error_enum_v0 - ) - + return self.kind== other.kind and self.function_v0== other.function_v0 and self.udt_struct_v0== other.udt_struct_v0 and self.udt_union_v0== other.udt_union_v0 and self.udt_enum_v0== other.udt_enum_v0 and self.udt_error_enum_v0== other.udt_error_enum_v0 def __str__(self): out = [] - out.append(f"kind={self.kind}") - out.append( - f"function_v0={self.function_v0}" - ) if self.function_v0 is not None else None - out.append( - f"udt_struct_v0={self.udt_struct_v0}" - ) if self.udt_struct_v0 is not None else None - out.append( - f"udt_union_v0={self.udt_union_v0}" - ) if self.udt_union_v0 is not None else None - out.append( - f"udt_enum_v0={self.udt_enum_v0}" - ) if self.udt_enum_v0 is not None else None - out.append( - f"udt_error_enum_v0={self.udt_error_enum_v0}" - ) if self.udt_error_enum_v0 is not None else None + out.append(f'kind={self.kind}') + out.append(f'function_v0={self.function_v0}') if self.function_v0 is not None else None + out.append(f'udt_struct_v0={self.udt_struct_v0}') if self.udt_struct_v0 is not None else None + out.append(f'udt_union_v0={self.udt_union_v0}') if self.udt_union_v0 is not None else None + out.append(f'udt_enum_v0={self.udt_enum_v0}') if self.udt_enum_v0 is not None else None + out.append(f'udt_error_enum_v0={self.udt_error_enum_v0}') if self.udt_error_enum_v0 is not None else None return f"" diff --git a/stellar_sdk/xdr/sc_spec_entry_kind.py b/stellar_sdk/xdr/sc_spec_entry_kind.py index 4fbe9b36..a10558ca 100644 --- a/stellar_sdk/xdr/sc_spec_entry_kind.py +++ b/stellar_sdk/xdr/sc_spec_entry_kind.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCSpecEntryKind"] - - +__all__ = ['SCSpecEntryKind'] class SCSpecEntryKind(IntEnum): """ XDR Source Code:: @@ -23,13 +23,11 @@ class SCSpecEntryKind(IntEnum): SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0 = 4 }; """ - SC_SPEC_ENTRY_FUNCTION_V0 = 0 SC_SPEC_ENTRY_UDT_STRUCT_V0 = 1 SC_SPEC_ENTRY_UDT_UNION_V0 = 2 SC_SPEC_ENTRY_UDT_ENUM_V0 = 3 SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0 = 4 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -37,7 +35,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCSpecEntryKind: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_spec_function_input_v0.py b/stellar_sdk/xdr/sc_spec_function_input_v0.py index ab2e36f5..fd8b2119 100644 --- a/stellar_sdk/xdr/sc_spec_function_input_v0.py +++ b/stellar_sdk/xdr/sc_spec_function_input_v0.py @@ -3,16 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .sc_spec_type_def import SCSpecTypeDef - -__all__ = ["SCSpecFunctionInputV0"] - +from .sc_spec_type_def import SCSpecTypeDef +__all__ = ['SCSpecFunctionInputV0'] class SCSpecFunctionInputV0: """ XDR Source Code:: @@ -24,7 +22,6 @@ class SCSpecFunctionInputV0: SCSpecTypeDef type; }; """ - def __init__( self, doc: bytes, @@ -34,12 +31,10 @@ def __init__( self.doc = doc self.name = name self.type = type - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.name, 30).pack(packer) self.type.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecFunctionInputV0: doc = String.unpack(unpacker) @@ -50,7 +45,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecFunctionInputV0: name=name, type=type, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +63,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecFunctionInputV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.name, - self.type, - ) - ) - + return hash((self.doc, self.name, self.type,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.name == other.name - and self.type == other.type - ) - + return self.doc== other.doc and self.name== other.name and self.type== other.type def __str__(self): out = [ - f"doc={self.doc}", - f"name={self.name}", - f"type={self.type}", + f'doc={self.doc}', + f'name={self.name}', + f'type={self.type}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_function_v0.py b/stellar_sdk/xdr/sc_spec_function_v0.py index fd370fa4..19af748a 100644 --- a/stellar_sdk/xdr/sc_spec_function_v0.py +++ b/stellar_sdk/xdr/sc_spec_function_v0.py @@ -3,19 +3,16 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * + +from .sc_symbol import SCSymbol from .sc_spec_function_input_v0 import SCSpecFunctionInputV0 from .sc_spec_type_def import SCSpecTypeDef -from .sc_symbol import SCSymbol - -__all__ = ["SCSpecFunctionV0"] - - +__all__ = ['SCSpecFunctionV0'] class SCSpecFunctionV0: """ XDR Source Code:: @@ -28,7 +25,6 @@ class SCSpecFunctionV0: SCSpecTypeDef outputs<1>; }; """ - def __init__( self, doc: bytes, @@ -38,19 +34,14 @@ def __init__( ) -> None: _expect_max_length = 10 if inputs and len(inputs) > _expect_max_length: - raise ValueError( - f"The maximum length of `inputs` should be {_expect_max_length}, but got {len(inputs)}." - ) + raise ValueError(f"The maximum length of `inputs` should be {_expect_max_length}, but got {len(inputs)}.") _expect_max_length = 1 if outputs and len(outputs) > _expect_max_length: - raise ValueError( - f"The maximum length of `outputs` should be {_expect_max_length}, but got {len(outputs)}." - ) + raise ValueError(f"The maximum length of `outputs` should be {_expect_max_length}, but got {len(outputs)}.") self.doc = doc self.name = name self.inputs = inputs self.outputs = outputs - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) self.name.pack(packer) @@ -60,7 +51,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.outputs)) for outputs_item in self.outputs: outputs_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecFunctionV0: doc = String.unpack(unpacker) @@ -79,7 +69,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecFunctionV0: inputs=inputs, outputs=outputs, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -98,32 +87,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecFunctionV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.name, - self.inputs, - self.outputs, - ) - ) - + return hash((self.doc, self.name, self.inputs, self.outputs,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.name == other.name - and self.inputs == other.inputs - and self.outputs == other.outputs - ) - + return self.doc== other.doc and self.name== other.name and self.inputs== other.inputs and self.outputs== other.outputs def __str__(self): out = [ - f"doc={self.doc}", - f"name={self.name}", - f"inputs={self.inputs}", - f"outputs={self.outputs}", + f'doc={self.doc}', + f'name={self.name}', + f'inputs={self.inputs}', + f'outputs={self.outputs}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_type.py b/stellar_sdk/xdr/sc_spec_type.py index 84a1525c..0014c757 100644 --- a/stellar_sdk/xdr/sc_spec_type.py +++ b/stellar_sdk/xdr/sc_spec_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCSpecType"] - - +__all__ = ['SCSpecType'] class SCSpecType(IntEnum): """ XDR Source Code:: @@ -49,7 +49,6 @@ class SCSpecType(IntEnum): SC_SPEC_TYPE_UDT = 2000 }; """ - SC_SPEC_TYPE_VAL = 0 SC_SPEC_TYPE_BOOL = 1 SC_SPEC_TYPE_VOID = 2 @@ -75,7 +74,6 @@ class SCSpecType(IntEnum): SC_SPEC_TYPE_TUPLE = 1005 SC_SPEC_TYPE_BYTES_N = 1006 SC_SPEC_TYPE_UDT = 2000 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -83,7 +81,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCSpecType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_spec_type_bytes_n.py b/stellar_sdk/xdr/sc_spec_type_bytes_n.py index 3a65330f..f0161cdb 100644 --- a/stellar_sdk/xdr/sc_spec_type_bytes_n.py +++ b/stellar_sdk/xdr/sc_spec_type_bytes_n.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint32 import Uint32 - -__all__ = ["SCSpecTypeBytesN"] - - +__all__ = ['SCSpecTypeBytesN'] class SCSpecTypeBytesN: """ XDR Source Code:: @@ -20,23 +20,19 @@ class SCSpecTypeBytesN: uint32 n; }; """ - def __init__( self, n: Uint32, ) -> None: self.n = n - def pack(self, packer: Packer) -> None: self.n.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecTypeBytesN: n = Uint32.unpack(unpacker) return cls( n=n, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecTypeBytesN: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.n,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.n == other.n - + return self.n== other.n def __str__(self): out = [ - f"n={self.n}", + f'n={self.n}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_type_def.py b/stellar_sdk/xdr/sc_spec_type_def.py index 27d9f552..59a51737 100644 --- a/stellar_sdk/xdr/sc_spec_type_def.py +++ b/stellar_sdk/xdr/sc_spec_type_def.py @@ -3,23 +3,22 @@ from __future__ import annotations import base64 -from typing import TYPE_CHECKING - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_spec_type import SCSpecType - if TYPE_CHECKING: - from .sc_spec_type_bytes_n import SCSpecTypeBytesN - from .sc_spec_type_map import SCSpecTypeMap from .sc_spec_type_option import SCSpecTypeOption from .sc_spec_type_result import SCSpecTypeResult + from .sc_spec_type_vec import SCSpecTypeVec + from .sc_spec_type_map import SCSpecTypeMap from .sc_spec_type_tuple import SCSpecTypeTuple + from .sc_spec_type_bytes_n import SCSpecTypeBytesN from .sc_spec_type_udt import SCSpecTypeUDT - from .sc_spec_type_vec import SCSpecTypeVec -__all__ = ["SCSpecTypeDef"] - - +__all__ = ['SCSpecTypeDef'] class SCSpecTypeDef: """ XDR Source Code:: @@ -61,7 +60,6 @@ class SCSpecTypeDef: SCSpecTypeUDT udt; }; """ - def __init__( self, type: SCSpecType, @@ -81,7 +79,6 @@ def __init__( self.tuple = tuple self.bytes_n = bytes_n self.udt = udt - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == SCSpecType.SC_SPEC_TYPE_VAL: @@ -155,7 +152,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("udt should not be None.") self.udt.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecTypeDef: type = SCSpecType.unpack(unpacker) @@ -197,41 +193,33 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecTypeDef: return cls(type=type) if type == SCSpecType.SC_SPEC_TYPE_OPTION: from .sc_spec_type_option import SCSpecTypeOption - option = SCSpecTypeOption.unpack(unpacker) return cls(type=type, option=option) if type == SCSpecType.SC_SPEC_TYPE_RESULT: from .sc_spec_type_result import SCSpecTypeResult - result = SCSpecTypeResult.unpack(unpacker) return cls(type=type, result=result) if type == SCSpecType.SC_SPEC_TYPE_VEC: from .sc_spec_type_vec import SCSpecTypeVec - vec = SCSpecTypeVec.unpack(unpacker) return cls(type=type, vec=vec) if type == SCSpecType.SC_SPEC_TYPE_MAP: from .sc_spec_type_map import SCSpecTypeMap - map = SCSpecTypeMap.unpack(unpacker) return cls(type=type, map=map) if type == SCSpecType.SC_SPEC_TYPE_TUPLE: from .sc_spec_type_tuple import SCSpecTypeTuple - tuple = SCSpecTypeTuple.unpack(unpacker) return cls(type=type, tuple=tuple) if type == SCSpecType.SC_SPEC_TYPE_BYTES_N: from .sc_spec_type_bytes_n import SCSpecTypeBytesN - bytes_n = SCSpecTypeBytesN.unpack(unpacker) return cls(type=type, bytes_n=bytes_n) if type == SCSpecType.SC_SPEC_TYPE_UDT: from .sc_spec_type_udt import SCSpecTypeUDT - udt = SCSpecTypeUDT.unpack(unpacker) return cls(type=type, udt=udt) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -250,43 +238,20 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecTypeDef: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.option, - self.result, - self.vec, - self.map, - self.tuple, - self.bytes_n, - self.udt, - ) - ) - + return hash((self.type, self.option, self.result, self.vec, self.map, self.tuple, self.bytes_n, self.udt,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.option == other.option - and self.result == other.result - and self.vec == other.vec - and self.map == other.map - and self.tuple == other.tuple - and self.bytes_n == other.bytes_n - and self.udt == other.udt - ) - + return self.type== other.type and self.option== other.option and self.result== other.result and self.vec== other.vec and self.map== other.map and self.tuple== other.tuple and self.bytes_n== other.bytes_n and self.udt== other.udt def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"option={self.option}") if self.option is not None else None - out.append(f"result={self.result}") if self.result is not None else None - out.append(f"vec={self.vec}") if self.vec is not None else None - out.append(f"map={self.map}") if self.map is not None else None - out.append(f"tuple={self.tuple}") if self.tuple is not None else None - out.append(f"bytes_n={self.bytes_n}") if self.bytes_n is not None else None - out.append(f"udt={self.udt}") if self.udt is not None else None + out.append(f'type={self.type}') + out.append(f'option={self.option}') if self.option is not None else None + out.append(f'result={self.result}') if self.result is not None else None + out.append(f'vec={self.vec}') if self.vec is not None else None + out.append(f'map={self.map}') if self.map is not None else None + out.append(f'tuple={self.tuple}') if self.tuple is not None else None + out.append(f'bytes_n={self.bytes_n}') if self.bytes_n is not None else None + out.append(f'udt={self.udt}') if self.udt is not None else None return f"" diff --git a/stellar_sdk/xdr/sc_spec_type_map.py b/stellar_sdk/xdr/sc_spec_type_map.py index cb126577..a706a7a3 100644 --- a/stellar_sdk/xdr/sc_spec_type_map.py +++ b/stellar_sdk/xdr/sc_spec_type_map.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_spec_type_def import SCSpecTypeDef - -__all__ = ["SCSpecTypeMap"] - - +from .sc_spec_type_def import SCSpecTypeDef +__all__ = ['SCSpecTypeMap'] class SCSpecTypeMap: """ XDR Source Code:: @@ -21,7 +22,6 @@ class SCSpecTypeMap: SCSpecTypeDef valueType; }; """ - def __init__( self, key_type: SCSpecTypeDef, @@ -29,11 +29,9 @@ def __init__( ) -> None: self.key_type = key_type self.value_type = value_type - def pack(self, packer: Packer) -> None: self.key_type.pack(packer) self.value_type.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecTypeMap: key_type = SCSpecTypeDef.unpack(unpacker) @@ -42,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecTypeMap: key_type=key_type, value_type=value_type, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecTypeMap: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.key_type, - self.value_type, - ) - ) - + return hash((self.key_type, self.value_type,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.key_type == other.key_type and self.value_type == other.value_type - + return self.key_type== other.key_type and self.value_type== other.value_type def __str__(self): out = [ - f"key_type={self.key_type}", - f"value_type={self.value_type}", + f'key_type={self.key_type}', + f'value_type={self.value_type}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_type_option.py b/stellar_sdk/xdr/sc_spec_type_option.py index 29a68bca..1512e308 100644 --- a/stellar_sdk/xdr/sc_spec_type_option.py +++ b/stellar_sdk/xdr/sc_spec_type_option.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_spec_type_def import SCSpecTypeDef - -__all__ = ["SCSpecTypeOption"] - - +__all__ = ['SCSpecTypeOption'] class SCSpecTypeOption: """ XDR Source Code:: @@ -20,23 +20,19 @@ class SCSpecTypeOption: SCSpecTypeDef valueType; }; """ - def __init__( self, value_type: SCSpecTypeDef, ) -> None: self.value_type = value_type - def pack(self, packer: Packer) -> None: self.value_type.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecTypeOption: value_type = SCSpecTypeDef.unpack(unpacker) return cls( value_type=value_type, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecTypeOption: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.value_type,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.value_type == other.value_type - + return self.value_type== other.value_type def __str__(self): out = [ - f"value_type={self.value_type}", + f'value_type={self.value_type}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_type_result.py b/stellar_sdk/xdr/sc_spec_type_result.py index 94fdc985..480d97df 100644 --- a/stellar_sdk/xdr/sc_spec_type_result.py +++ b/stellar_sdk/xdr/sc_spec_type_result.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_spec_type_def import SCSpecTypeDef - -__all__ = ["SCSpecTypeResult"] - - +from .sc_spec_type_def import SCSpecTypeDef +__all__ = ['SCSpecTypeResult'] class SCSpecTypeResult: """ XDR Source Code:: @@ -21,7 +22,6 @@ class SCSpecTypeResult: SCSpecTypeDef errorType; }; """ - def __init__( self, ok_type: SCSpecTypeDef, @@ -29,11 +29,9 @@ def __init__( ) -> None: self.ok_type = ok_type self.error_type = error_type - def pack(self, packer: Packer) -> None: self.ok_type.pack(packer) self.error_type.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecTypeResult: ok_type = SCSpecTypeDef.unpack(unpacker) @@ -42,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecTypeResult: ok_type=ok_type, error_type=error_type, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecTypeResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ok_type, - self.error_type, - ) - ) - + return hash((self.ok_type, self.error_type,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.ok_type == other.ok_type and self.error_type == other.error_type - + return self.ok_type== other.ok_type and self.error_type== other.error_type def __str__(self): out = [ - f"ok_type={self.ok_type}", - f"error_type={self.error_type}", + f'ok_type={self.ok_type}', + f'error_type={self.error_type}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_type_tuple.py b/stellar_sdk/xdr/sc_spec_type_tuple.py index 4e4c14d5..4c8c7a6f 100644 --- a/stellar_sdk/xdr/sc_spec_type_tuple.py +++ b/stellar_sdk/xdr/sc_spec_type_tuple.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_spec_type_def import SCSpecTypeDef - -__all__ = ["SCSpecTypeTuple"] - - +__all__ = ['SCSpecTypeTuple'] class SCSpecTypeTuple: """ XDR Source Code:: @@ -21,23 +20,18 @@ class SCSpecTypeTuple: SCSpecTypeDef valueTypes<12>; }; """ - def __init__( self, value_types: List[SCSpecTypeDef], ) -> None: _expect_max_length = 12 if value_types and len(value_types) > _expect_max_length: - raise ValueError( - f"The maximum length of `value_types` should be {_expect_max_length}, but got {len(value_types)}." - ) + raise ValueError(f"The maximum length of `value_types` should be {_expect_max_length}, but got {len(value_types)}.") self.value_types = value_types - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.value_types)) for value_types_item in self.value_types: value_types_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecTypeTuple: length = unpacker.unpack_uint() @@ -47,7 +41,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecTypeTuple: return cls( value_types=value_types, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -66,17 +59,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecTypeTuple: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.value_types,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.value_types == other.value_types - + return self.value_types== other.value_types def __str__(self): out = [ - f"value_types={self.value_types}", + f'value_types={self.value_types}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_type_udt.py b/stellar_sdk/xdr/sc_spec_type_udt.py index e67a19ed..ee8e64a6 100644 --- a/stellar_sdk/xdr/sc_spec_type_udt.py +++ b/stellar_sdk/xdr/sc_spec_type_udt.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import String - -__all__ = ["SCSpecTypeUDT"] - - +__all__ = ['SCSpecTypeUDT'] class SCSpecTypeUDT: """ XDR Source Code:: @@ -20,23 +19,19 @@ class SCSpecTypeUDT: string name<60>; }; """ - def __init__( self, name: bytes, ) -> None: self.name = name - def pack(self, packer: Packer) -> None: String(self.name, 60).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecTypeUDT: name = String.unpack(unpacker) return cls( name=name, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +50,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecTypeUDT: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.name,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.name == other.name - + return self.name== other.name def __str__(self): out = [ - f"name={self.name}", + f'name={self.name}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_type_vec.py b/stellar_sdk/xdr/sc_spec_type_vec.py index 4dbbb443..2e1fe661 100644 --- a/stellar_sdk/xdr/sc_spec_type_vec.py +++ b/stellar_sdk/xdr/sc_spec_type_vec.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_spec_type_def import SCSpecTypeDef - -__all__ = ["SCSpecTypeVec"] - - +__all__ = ['SCSpecTypeVec'] class SCSpecTypeVec: """ XDR Source Code:: @@ -20,23 +20,19 @@ class SCSpecTypeVec: SCSpecTypeDef elementType; }; """ - def __init__( self, element_type: SCSpecTypeDef, ) -> None: self.element_type = element_type - def pack(self, packer: Packer) -> None: self.element_type.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecTypeVec: element_type = SCSpecTypeDef.unpack(unpacker) return cls( element_type=element_type, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecTypeVec: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.element_type,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.element_type == other.element_type - + return self.element_type== other.element_type def __str__(self): out = [ - f"element_type={self.element_type}", + f'element_type={self.element_type}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_enum_case_v0.py b/stellar_sdk/xdr/sc_spec_udt_enum_case_v0.py index 730f4e1d..111d10d7 100644 --- a/stellar_sdk/xdr/sc_spec_udt_enum_case_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_enum_case_v0.py @@ -3,16 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .uint32 import Uint32 - -__all__ = ["SCSpecUDTEnumCaseV0"] - +from .uint32 import Uint32 +__all__ = ['SCSpecUDTEnumCaseV0'] class SCSpecUDTEnumCaseV0: """ XDR Source Code:: @@ -24,7 +22,6 @@ class SCSpecUDTEnumCaseV0: uint32 value; }; """ - def __init__( self, doc: bytes, @@ -34,12 +31,10 @@ def __init__( self.doc = doc self.name = name self.value = value - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.name, 60).pack(packer) self.value.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTEnumCaseV0: doc = String.unpack(unpacker) @@ -50,7 +45,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTEnumCaseV0: name=name, value=value, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +63,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTEnumCaseV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.name, - self.value, - ) - ) - + return hash((self.doc, self.name, self.value,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.name == other.name - and self.value == other.value - ) - + return self.doc== other.doc and self.name== other.name and self.value== other.value def __str__(self): out = [ - f"doc={self.doc}", - f"name={self.name}", - f"value={self.value}", + f'doc={self.doc}', + f'name={self.name}', + f'value={self.value}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_enum_v0.py b/stellar_sdk/xdr/sc_spec_udt_enum_v0.py index 86ef6393..f6756a43 100644 --- a/stellar_sdk/xdr/sc_spec_udt_enum_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_enum_v0.py @@ -3,17 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .sc_spec_udt_enum_case_v0 import SCSpecUDTEnumCaseV0 - -__all__ = ["SCSpecUDTEnumV0"] - +from .sc_spec_udt_enum_case_v0 import SCSpecUDTEnumCaseV0 +__all__ = ['SCSpecUDTEnumV0'] class SCSpecUDTEnumV0: """ XDR Source Code:: @@ -26,7 +23,6 @@ class SCSpecUDTEnumV0: SCSpecUDTEnumCaseV0 cases<50>; }; """ - def __init__( self, doc: bytes, @@ -36,14 +32,11 @@ def __init__( ) -> None: _expect_max_length = 50 if cases and len(cases) > _expect_max_length: - raise ValueError( - f"The maximum length of `cases` should be {_expect_max_length}, but got {len(cases)}." - ) + raise ValueError(f"The maximum length of `cases` should be {_expect_max_length}, but got {len(cases)}.") self.doc = doc self.lib = lib self.name = name self.cases = cases - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.lib, 80).pack(packer) @@ -51,7 +44,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.cases)) for cases_item in self.cases: cases_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTEnumV0: doc = String.unpack(unpacker) @@ -67,7 +59,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTEnumV0: name=name, cases=cases, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -86,32 +77,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTEnumV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.lib, - self.name, - self.cases, - ) - ) - + return hash((self.doc, self.lib, self.name, self.cases,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.lib == other.lib - and self.name == other.name - and self.cases == other.cases - ) - + return self.doc== other.doc and self.lib== other.lib and self.name== other.name and self.cases== other.cases def __str__(self): out = [ - f"doc={self.doc}", - f"lib={self.lib}", - f"name={self.name}", - f"cases={self.cases}", + f'doc={self.doc}', + f'lib={self.lib}', + f'name={self.name}', + f'cases={self.cases}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_error_enum_case_v0.py b/stellar_sdk/xdr/sc_spec_udt_error_enum_case_v0.py index e2df585a..e0214bc7 100644 --- a/stellar_sdk/xdr/sc_spec_udt_error_enum_case_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_error_enum_case_v0.py @@ -3,16 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .uint32 import Uint32 - -__all__ = ["SCSpecUDTErrorEnumCaseV0"] - +from .uint32 import Uint32 +__all__ = ['SCSpecUDTErrorEnumCaseV0'] class SCSpecUDTErrorEnumCaseV0: """ XDR Source Code:: @@ -24,7 +22,6 @@ class SCSpecUDTErrorEnumCaseV0: uint32 value; }; """ - def __init__( self, doc: bytes, @@ -34,12 +31,10 @@ def __init__( self.doc = doc self.name = name self.value = value - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.name, 60).pack(packer) self.value.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTErrorEnumCaseV0: doc = String.unpack(unpacker) @@ -50,7 +45,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTErrorEnumCaseV0: name=name, value=value, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +63,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTErrorEnumCaseV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.name, - self.value, - ) - ) - + return hash((self.doc, self.name, self.value,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.name == other.name - and self.value == other.value - ) - + return self.doc== other.doc and self.name== other.name and self.value== other.value def __str__(self): out = [ - f"doc={self.doc}", - f"name={self.name}", - f"value={self.value}", + f'doc={self.doc}', + f'name={self.name}', + f'value={self.value}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_error_enum_v0.py b/stellar_sdk/xdr/sc_spec_udt_error_enum_v0.py index fe1d8e25..01f43ddb 100644 --- a/stellar_sdk/xdr/sc_spec_udt_error_enum_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_error_enum_v0.py @@ -3,17 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .sc_spec_udt_error_enum_case_v0 import SCSpecUDTErrorEnumCaseV0 - -__all__ = ["SCSpecUDTErrorEnumV0"] - +from .sc_spec_udt_error_enum_case_v0 import SCSpecUDTErrorEnumCaseV0 +__all__ = ['SCSpecUDTErrorEnumV0'] class SCSpecUDTErrorEnumV0: """ XDR Source Code:: @@ -26,7 +23,6 @@ class SCSpecUDTErrorEnumV0: SCSpecUDTErrorEnumCaseV0 cases<50>; }; """ - def __init__( self, doc: bytes, @@ -36,14 +32,11 @@ def __init__( ) -> None: _expect_max_length = 50 if cases and len(cases) > _expect_max_length: - raise ValueError( - f"The maximum length of `cases` should be {_expect_max_length}, but got {len(cases)}." - ) + raise ValueError(f"The maximum length of `cases` should be {_expect_max_length}, but got {len(cases)}.") self.doc = doc self.lib = lib self.name = name self.cases = cases - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.lib, 80).pack(packer) @@ -51,7 +44,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.cases)) for cases_item in self.cases: cases_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTErrorEnumV0: doc = String.unpack(unpacker) @@ -67,7 +59,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTErrorEnumV0: name=name, cases=cases, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -86,32 +77,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTErrorEnumV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.lib, - self.name, - self.cases, - ) - ) - + return hash((self.doc, self.lib, self.name, self.cases,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.lib == other.lib - and self.name == other.name - and self.cases == other.cases - ) - + return self.doc== other.doc and self.lib== other.lib and self.name== other.name and self.cases== other.cases def __str__(self): out = [ - f"doc={self.doc}", - f"lib={self.lib}", - f"name={self.name}", - f"cases={self.cases}", + f'doc={self.doc}', + f'lib={self.lib}', + f'name={self.name}', + f'cases={self.cases}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_struct_field_v0.py b/stellar_sdk/xdr/sc_spec_udt_struct_field_v0.py index c23621d6..aa10e0f1 100644 --- a/stellar_sdk/xdr/sc_spec_udt_struct_field_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_struct_field_v0.py @@ -3,16 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .sc_spec_type_def import SCSpecTypeDef - -__all__ = ["SCSpecUDTStructFieldV0"] - +from .sc_spec_type_def import SCSpecTypeDef +__all__ = ['SCSpecUDTStructFieldV0'] class SCSpecUDTStructFieldV0: """ XDR Source Code:: @@ -24,7 +22,6 @@ class SCSpecUDTStructFieldV0: SCSpecTypeDef type; }; """ - def __init__( self, doc: bytes, @@ -34,12 +31,10 @@ def __init__( self.doc = doc self.name = name self.type = type - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.name, 30).pack(packer) self.type.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTStructFieldV0: doc = String.unpack(unpacker) @@ -50,7 +45,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTStructFieldV0: name=name, type=type, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +63,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTStructFieldV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.name, - self.type, - ) - ) - + return hash((self.doc, self.name, self.type,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.name == other.name - and self.type == other.type - ) - + return self.doc== other.doc and self.name== other.name and self.type== other.type def __str__(self): out = [ - f"doc={self.doc}", - f"name={self.name}", - f"type={self.type}", + f'doc={self.doc}', + f'name={self.name}', + f'type={self.type}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_struct_v0.py b/stellar_sdk/xdr/sc_spec_udt_struct_v0.py index 223f174b..d8f21f7d 100644 --- a/stellar_sdk/xdr/sc_spec_udt_struct_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_struct_v0.py @@ -3,17 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .sc_spec_udt_struct_field_v0 import SCSpecUDTStructFieldV0 - -__all__ = ["SCSpecUDTStructV0"] - +from .sc_spec_udt_struct_field_v0 import SCSpecUDTStructFieldV0 +__all__ = ['SCSpecUDTStructV0'] class SCSpecUDTStructV0: """ XDR Source Code:: @@ -26,7 +23,6 @@ class SCSpecUDTStructV0: SCSpecUDTStructFieldV0 fields<40>; }; """ - def __init__( self, doc: bytes, @@ -36,14 +32,11 @@ def __init__( ) -> None: _expect_max_length = 40 if fields and len(fields) > _expect_max_length: - raise ValueError( - f"The maximum length of `fields` should be {_expect_max_length}, but got {len(fields)}." - ) + raise ValueError(f"The maximum length of `fields` should be {_expect_max_length}, but got {len(fields)}.") self.doc = doc self.lib = lib self.name = name self.fields = fields - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.lib, 80).pack(packer) @@ -51,7 +44,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.fields)) for fields_item in self.fields: fields_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTStructV0: doc = String.unpack(unpacker) @@ -67,7 +59,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTStructV0: name=name, fields=fields, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -86,32 +77,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTStructV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.lib, - self.name, - self.fields, - ) - ) - + return hash((self.doc, self.lib, self.name, self.fields,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.lib == other.lib - and self.name == other.name - and self.fields == other.fields - ) - + return self.doc== other.doc and self.lib== other.lib and self.name== other.name and self.fields== other.fields def __str__(self): out = [ - f"doc={self.doc}", - f"lib={self.lib}", - f"name={self.name}", - f"fields={self.fields}", + f'doc={self.doc}', + f'lib={self.lib}', + f'name={self.name}', + f'fields={self.fields}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_union_case_tuple_v0.py b/stellar_sdk/xdr/sc_spec_udt_union_case_tuple_v0.py index 26296634..60f4b613 100644 --- a/stellar_sdk/xdr/sc_spec_udt_union_case_tuple_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_union_case_tuple_v0.py @@ -3,17 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .sc_spec_type_def import SCSpecTypeDef - -__all__ = ["SCSpecUDTUnionCaseTupleV0"] - +from .sc_spec_type_def import SCSpecTypeDef +__all__ = ['SCSpecUDTUnionCaseTupleV0'] class SCSpecUDTUnionCaseTupleV0: """ XDR Source Code:: @@ -25,7 +22,6 @@ class SCSpecUDTUnionCaseTupleV0: SCSpecTypeDef type<12>; }; """ - def __init__( self, doc: bytes, @@ -34,20 +30,16 @@ def __init__( ) -> None: _expect_max_length = 12 if type and len(type) > _expect_max_length: - raise ValueError( - f"The maximum length of `type` should be {_expect_max_length}, but got {len(type)}." - ) + raise ValueError(f"The maximum length of `type` should be {_expect_max_length}, but got {len(type)}.") self.doc = doc self.name = name self.type = type - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.name, 60).pack(packer) packer.pack_uint(len(self.type)) for type_item in self.type: type_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionCaseTupleV0: doc = String.unpack(unpacker) @@ -61,7 +53,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionCaseTupleV0: name=name, type=type, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -80,29 +71,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTUnionCaseTupleV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.name, - self.type, - ) - ) - + return hash((self.doc, self.name, self.type,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.name == other.name - and self.type == other.type - ) - + return self.doc== other.doc and self.name== other.name and self.type== other.type def __str__(self): out = [ - f"doc={self.doc}", - f"name={self.name}", - f"type={self.type}", + f'doc={self.doc}', + f'name={self.name}', + f'type={self.type}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_union_case_v0.py b/stellar_sdk/xdr/sc_spec_udt_union_case_v0.py index bb8014cb..87018ee2 100644 --- a/stellar_sdk/xdr/sc_spec_udt_union_case_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_union_case_v0.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .sc_spec_udt_union_case_tuple_v0 import SCSpecUDTUnionCaseTupleV0 from .sc_spec_udt_union_case_v0_kind import SCSpecUDTUnionCaseV0Kind from .sc_spec_udt_union_case_void_v0 import SCSpecUDTUnionCaseVoidV0 - -__all__ = ["SCSpecUDTUnionCaseV0"] - - +from .sc_spec_udt_union_case_tuple_v0 import SCSpecUDTUnionCaseTupleV0 +__all__ = ['SCSpecUDTUnionCaseV0'] class SCSpecUDTUnionCaseV0: """ XDR Source Code:: @@ -25,7 +25,6 @@ class SCSpecUDTUnionCaseV0: SCSpecUDTUnionCaseTupleV0 tupleCase; }; """ - def __init__( self, kind: SCSpecUDTUnionCaseV0Kind, @@ -35,7 +34,6 @@ def __init__( self.kind = kind self.void_case = void_case self.tuple_case = tuple_case - def pack(self, packer: Packer) -> None: self.kind.pack(packer) if self.kind == SCSpecUDTUnionCaseV0Kind.SC_SPEC_UDT_UNION_CASE_VOID_V0: @@ -48,7 +46,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("tuple_case should not be None.") self.tuple_case.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionCaseV0: kind = SCSpecUDTUnionCaseV0Kind.unpack(unpacker) @@ -59,7 +56,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionCaseV0: tuple_case = SCSpecUDTUnionCaseTupleV0.unpack(unpacker) return cls(kind=kind, tuple_case=tuple_case) return cls(kind=kind) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -78,32 +74,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTUnionCaseV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.kind, - self.void_case, - self.tuple_case, - ) - ) - + return hash((self.kind, self.void_case, self.tuple_case,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.kind == other.kind - and self.void_case == other.void_case - and self.tuple_case == other.tuple_case - ) - + return self.kind== other.kind and self.void_case== other.void_case and self.tuple_case== other.tuple_case def __str__(self): out = [] - out.append(f"kind={self.kind}") - out.append( - f"void_case={self.void_case}" - ) if self.void_case is not None else None - out.append( - f"tuple_case={self.tuple_case}" - ) if self.tuple_case is not None else None + out.append(f'kind={self.kind}') + out.append(f'void_case={self.void_case}') if self.void_case is not None else None + out.append(f'tuple_case={self.tuple_case}') if self.tuple_case is not None else None return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_union_case_v0_kind.py b/stellar_sdk/xdr/sc_spec_udt_union_case_v0_kind.py index 53ac28bf..5b59f8c4 100644 --- a/stellar_sdk/xdr/sc_spec_udt_union_case_v0_kind.py +++ b/stellar_sdk/xdr/sc_spec_udt_union_case_v0_kind.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCSpecUDTUnionCaseV0Kind"] - - +__all__ = ['SCSpecUDTUnionCaseV0Kind'] class SCSpecUDTUnionCaseV0Kind(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class SCSpecUDTUnionCaseV0Kind(IntEnum): SC_SPEC_UDT_UNION_CASE_TUPLE_V0 = 1 }; """ - SC_SPEC_UDT_UNION_CASE_VOID_V0 = 0 SC_SPEC_UDT_UNION_CASE_TUPLE_V0 = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionCaseV0Kind: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_spec_udt_union_case_void_v0.py b/stellar_sdk/xdr/sc_spec_udt_union_case_void_v0.py index 4439a16e..d8f416fa 100644 --- a/stellar_sdk/xdr/sc_spec_udt_union_case_void_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_union_case_void_v0.py @@ -3,15 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -__all__ = ["SCSpecUDTUnionCaseVoidV0"] - - +__all__ = ['SCSpecUDTUnionCaseVoidV0'] class SCSpecUDTUnionCaseVoidV0: """ XDR Source Code:: @@ -22,7 +20,6 @@ class SCSpecUDTUnionCaseVoidV0: string name<60>; }; """ - def __init__( self, doc: bytes, @@ -30,11 +27,9 @@ def __init__( ) -> None: self.doc = doc self.name = name - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.name, 60).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionCaseVoidV0: doc = String.unpack(unpacker) @@ -43,7 +38,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionCaseVoidV0: doc=doc, name=name, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +56,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTUnionCaseVoidV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.name, - ) - ) - + return hash((self.doc, self.name,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.doc == other.doc and self.name == other.name - + return self.doc== other.doc and self.name== other.name def __str__(self): out = [ - f"doc={self.doc}", - f"name={self.name}", + f'doc={self.doc}', + f'name={self.name}', ] return f"" diff --git a/stellar_sdk/xdr/sc_spec_udt_union_v0.py b/stellar_sdk/xdr/sc_spec_udt_union_v0.py index e7b6b3a7..75295e73 100644 --- a/stellar_sdk/xdr/sc_spec_udt_union_v0.py +++ b/stellar_sdk/xdr/sc_spec_udt_union_v0.py @@ -3,17 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .sc_spec_udt_union_case_v0 import SCSpecUDTUnionCaseV0 - -__all__ = ["SCSpecUDTUnionV0"] - +from .sc_spec_udt_union_case_v0 import SCSpecUDTUnionCaseV0 +__all__ = ['SCSpecUDTUnionV0'] class SCSpecUDTUnionV0: """ XDR Source Code:: @@ -26,7 +23,6 @@ class SCSpecUDTUnionV0: SCSpecUDTUnionCaseV0 cases<50>; }; """ - def __init__( self, doc: bytes, @@ -36,14 +32,11 @@ def __init__( ) -> None: _expect_max_length = 50 if cases and len(cases) > _expect_max_length: - raise ValueError( - f"The maximum length of `cases` should be {_expect_max_length}, but got {len(cases)}." - ) + raise ValueError(f"The maximum length of `cases` should be {_expect_max_length}, but got {len(cases)}.") self.doc = doc self.lib = lib self.name = name self.cases = cases - def pack(self, packer: Packer) -> None: String(self.doc, SC_SPEC_DOC_LIMIT).pack(packer) String(self.lib, 80).pack(packer) @@ -51,7 +44,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.cases)) for cases_item in self.cases: cases_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionV0: doc = String.unpack(unpacker) @@ -67,7 +59,6 @@ def unpack(cls, unpacker: Unpacker) -> SCSpecUDTUnionV0: name=name, cases=cases, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -86,32 +77,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSpecUDTUnionV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.doc, - self.lib, - self.name, - self.cases, - ) - ) - + return hash((self.doc, self.lib, self.name, self.cases,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.doc == other.doc - and self.lib == other.lib - and self.name == other.name - and self.cases == other.cases - ) - + return self.doc== other.doc and self.lib== other.lib and self.name== other.name and self.cases== other.cases def __str__(self): out = [ - f"doc={self.doc}", - f"lib={self.lib}", - f"name={self.name}", - f"cases={self.cases}", + f'doc={self.doc}', + f'lib={self.lib}', + f'name={self.name}', + f'cases={self.cases}', ] return f"" diff --git a/stellar_sdk/xdr/sc_string.py b/stellar_sdk/xdr/sc_string.py index 300a94ae..cbe9687a 100644 --- a/stellar_sdk/xdr/sc_string.py +++ b/stellar_sdk/xdr/sc_string.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import String - -__all__ = ["SCString"] - - +__all__ = ['SCString'] class SCString: """ XDR Source Code:: typedef string SCString<>; """ - def __init__(self, sc_string: bytes) -> None: self.sc_string = sc_string - def pack(self, packer: Packer) -> None: String(self.sc_string, 4294967295).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCString: sc_string = String.unpack(unpacker) return cls(sc_string) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCString: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.sc_string) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/sc_symbol.py b/stellar_sdk/xdr/sc_symbol.py index 44ca5574..729e43a9 100644 --- a/stellar_sdk/xdr/sc_symbol.py +++ b/stellar_sdk/xdr/sc_symbol.py @@ -3,33 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - -from .base import String +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -__all__ = ["SCSymbol"] - - +__all__ = ['SCSymbol'] class SCSymbol: """ XDR Source Code:: typedef string SCSymbol; """ - def __init__(self, sc_symbol: bytes) -> None: self.sc_symbol = sc_symbol - def pack(self, packer: Packer) -> None: String(self.sc_symbol, SCSYMBOL_LIMIT).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCSymbol: sc_symbol = String.unpack(unpacker) return cls(sc_symbol) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -48,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCSymbol: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.sc_symbol) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/sc_val.py b/stellar_sdk/xdr/sc_val.py index e868a689..03183463 100644 --- a/stellar_sdk/xdr/sc_val.py +++ b/stellar_sdk/xdr/sc_val.py @@ -3,36 +3,34 @@ from __future__ import annotations import base64 -from typing import TYPE_CHECKING, Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Boolean from .sc_val_type import SCValType - if TYPE_CHECKING: - from .duration import Duration + from .sc_error import SCError + from .uint32 import Uint32 from .int32 import Int32 + from .uint64 import Uint64 from .int64 import Int64 + from .time_point import TimePoint + from .duration import Duration + from .u_int128_parts import UInt128Parts from .int128_parts import Int128Parts + from .u_int256_parts import UInt256Parts from .int256_parts import Int256Parts - from .sc_address import SCAddress from .sc_bytes import SCBytes - from .sc_contract_instance import SCContractInstance - from .sc_error import SCError - from .sc_map import SCMap - from .sc_nonce_key import SCNonceKey from .sc_string import SCString from .sc_symbol import SCSymbol from .sc_vec import SCVec - from .time_point import TimePoint - from .u_int128_parts import UInt128Parts - from .u_int256_parts import UInt256Parts - from .uint32 import Uint32 - from .uint64 import Uint64 -__all__ = ["SCVal"] - - + from .sc_map import SCMap + from .sc_address import SCAddress + from .sc_nonce_key import SCNonceKey + from .sc_contract_instance import SCContractInstance +__all__ = ['SCVal'] class SCVal: """ XDR Source Code:: @@ -99,7 +97,6 @@ class SCVal: SCContractInstance instance; }; """ - def __init__( self, type: SCValType, @@ -145,7 +142,6 @@ def __init__( self.address = address self.nonce_key = nonce_key self.instance = instance - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == SCValType.SCV_BOOL: @@ -260,7 +256,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("instance should not be None.") self.instance.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCVal: type = SCValType.unpack(unpacker) @@ -271,103 +266,83 @@ def unpack(cls, unpacker: Unpacker) -> SCVal: return cls(type=type) if type == SCValType.SCV_ERROR: from .sc_error import SCError - error = SCError.unpack(unpacker) return cls(type=type, error=error) if type == SCValType.SCV_U32: from .uint32 import Uint32 - u32 = Uint32.unpack(unpacker) return cls(type=type, u32=u32) if type == SCValType.SCV_I32: from .int32 import Int32 - i32 = Int32.unpack(unpacker) return cls(type=type, i32=i32) if type == SCValType.SCV_U64: from .uint64 import Uint64 - u64 = Uint64.unpack(unpacker) return cls(type=type, u64=u64) if type == SCValType.SCV_I64: from .int64 import Int64 - i64 = Int64.unpack(unpacker) return cls(type=type, i64=i64) if type == SCValType.SCV_TIMEPOINT: from .time_point import TimePoint - timepoint = TimePoint.unpack(unpacker) return cls(type=type, timepoint=timepoint) if type == SCValType.SCV_DURATION: from .duration import Duration - duration = Duration.unpack(unpacker) return cls(type=type, duration=duration) if type == SCValType.SCV_U128: from .u_int128_parts import UInt128Parts - u128 = UInt128Parts.unpack(unpacker) return cls(type=type, u128=u128) if type == SCValType.SCV_I128: from .int128_parts import Int128Parts - i128 = Int128Parts.unpack(unpacker) return cls(type=type, i128=i128) if type == SCValType.SCV_U256: from .u_int256_parts import UInt256Parts - u256 = UInt256Parts.unpack(unpacker) return cls(type=type, u256=u256) if type == SCValType.SCV_I256: from .int256_parts import Int256Parts - i256 = Int256Parts.unpack(unpacker) return cls(type=type, i256=i256) if type == SCValType.SCV_BYTES: from .sc_bytes import SCBytes - bytes = SCBytes.unpack(unpacker) return cls(type=type, bytes=bytes) if type == SCValType.SCV_STRING: from .sc_string import SCString - str = SCString.unpack(unpacker) return cls(type=type, str=str) if type == SCValType.SCV_SYMBOL: from .sc_symbol import SCSymbol - sym = SCSymbol.unpack(unpacker) return cls(type=type, sym=sym) if type == SCValType.SCV_VEC: from .sc_vec import SCVec - vec = SCVec.unpack(unpacker) if unpacker.unpack_uint() else None return cls(type=type, vec=vec) if type == SCValType.SCV_MAP: from .sc_map import SCMap - map = SCMap.unpack(unpacker) if unpacker.unpack_uint() else None return cls(type=type, map=map) if type == SCValType.SCV_ADDRESS: from .sc_address import SCAddress - address = SCAddress.unpack(unpacker) return cls(type=type, address=address) if type == SCValType.SCV_LEDGER_KEY_CONTRACT_INSTANCE: return cls(type=type) if type == SCValType.SCV_LEDGER_KEY_NONCE: from .sc_nonce_key import SCNonceKey - nonce_key = SCNonceKey.unpack(unpacker) return cls(type=type, nonce_key=nonce_key) if type == SCValType.SCV_CONTRACT_INSTANCE: from .sc_contract_instance import SCContractInstance - instance = SCContractInstance.unpack(unpacker) return cls(type=type, instance=instance) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -386,86 +361,33 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCVal: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.b, - self.error, - self.u32, - self.i32, - self.u64, - self.i64, - self.timepoint, - self.duration, - self.u128, - self.i128, - self.u256, - self.i256, - self.bytes, - self.str, - self.sym, - self.vec, - self.map, - self.address, - self.nonce_key, - self.instance, - ) - ) - + return hash((self.type, self.b, self.error, self.u32, self.i32, self.u64, self.i64, self.timepoint, self.duration, self.u128, self.i128, self.u256, self.i256, self.bytes, self.str, self.sym, self.vec, self.map, self.address, self.nonce_key, self.instance,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.b == other.b - and self.error == other.error - and self.u32 == other.u32 - and self.i32 == other.i32 - and self.u64 == other.u64 - and self.i64 == other.i64 - and self.timepoint == other.timepoint - and self.duration == other.duration - and self.u128 == other.u128 - and self.i128 == other.i128 - and self.u256 == other.u256 - and self.i256 == other.i256 - and self.bytes == other.bytes - and self.str == other.str - and self.sym == other.sym - and self.vec == other.vec - and self.map == other.map - and self.address == other.address - and self.nonce_key == other.nonce_key - and self.instance == other.instance - ) - + return self.type== other.type and self.b== other.b and self.error== other.error and self.u32== other.u32 and self.i32== other.i32 and self.u64== other.u64 and self.i64== other.i64 and self.timepoint== other.timepoint and self.duration== other.duration and self.u128== other.u128 and self.i128== other.i128 and self.u256== other.u256 and self.i256== other.i256 and self.bytes== other.bytes and self.str== other.str and self.sym== other.sym and self.vec== other.vec and self.map== other.map and self.address== other.address and self.nonce_key== other.nonce_key and self.instance== other.instance def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"b={self.b}") if self.b is not None else None - out.append(f"error={self.error}") if self.error is not None else None - out.append(f"u32={self.u32}") if self.u32 is not None else None - out.append(f"i32={self.i32}") if self.i32 is not None else None - out.append(f"u64={self.u64}") if self.u64 is not None else None - out.append(f"i64={self.i64}") if self.i64 is not None else None - out.append( - f"timepoint={self.timepoint}" - ) if self.timepoint is not None else None - out.append(f"duration={self.duration}") if self.duration is not None else None - out.append(f"u128={self.u128}") if self.u128 is not None else None - out.append(f"i128={self.i128}") if self.i128 is not None else None - out.append(f"u256={self.u256}") if self.u256 is not None else None - out.append(f"i256={self.i256}") if self.i256 is not None else None - out.append(f"bytes={self.bytes}") if self.bytes is not None else None - out.append(f"str={self.str}") if self.str is not None else None - out.append(f"sym={self.sym}") if self.sym is not None else None - out.append(f"vec={self.vec}") if self.vec is not None else None - out.append(f"map={self.map}") if self.map is not None else None - out.append(f"address={self.address}") if self.address is not None else None - out.append( - f"nonce_key={self.nonce_key}" - ) if self.nonce_key is not None else None - out.append(f"instance={self.instance}") if self.instance is not None else None + out.append(f'type={self.type}') + out.append(f'b={self.b}') if self.b is not None else None + out.append(f'error={self.error}') if self.error is not None else None + out.append(f'u32={self.u32}') if self.u32 is not None else None + out.append(f'i32={self.i32}') if self.i32 is not None else None + out.append(f'u64={self.u64}') if self.u64 is not None else None + out.append(f'i64={self.i64}') if self.i64 is not None else None + out.append(f'timepoint={self.timepoint}') if self.timepoint is not None else None + out.append(f'duration={self.duration}') if self.duration is not None else None + out.append(f'u128={self.u128}') if self.u128 is not None else None + out.append(f'i128={self.i128}') if self.i128 is not None else None + out.append(f'u256={self.u256}') if self.u256 is not None else None + out.append(f'i256={self.i256}') if self.i256 is not None else None + out.append(f'bytes={self.bytes}') if self.bytes is not None else None + out.append(f'str={self.str}') if self.str is not None else None + out.append(f'sym={self.sym}') if self.sym is not None else None + out.append(f'vec={self.vec}') if self.vec is not None else None + out.append(f'map={self.map}') if self.map is not None else None + out.append(f'address={self.address}') if self.address is not None else None + out.append(f'nonce_key={self.nonce_key}') if self.nonce_key is not None else None + out.append(f'instance={self.instance}') if self.instance is not None else None return f"" diff --git a/stellar_sdk/xdr/sc_val_type.py b/stellar_sdk/xdr/sc_val_type.py index aef93dae..7df57587 100644 --- a/stellar_sdk/xdr/sc_val_type.py +++ b/stellar_sdk/xdr/sc_val_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCValType"] - - +__all__ = ['SCValType'] class SCValType(IntEnum): """ XDR Source Code:: @@ -59,7 +59,7 @@ class SCValType(IntEnum): SCV_ADDRESS = 18, // The following are the internal SCVal variants that are not - // exposed to the contracts. + // exposed to the contracts. SCV_CONTRACT_INSTANCE = 19, // SCV_LEDGER_KEY_CONTRACT_INSTANCE and SCV_LEDGER_KEY_NONCE are unique @@ -69,7 +69,6 @@ class SCValType(IntEnum): SCV_LEDGER_KEY_NONCE = 21 }; """ - SCV_BOOL = 0 SCV_VOID = 1 SCV_ERROR = 2 @@ -92,7 +91,6 @@ class SCValType(IntEnum): SCV_CONTRACT_INSTANCE = 19 SCV_LEDGER_KEY_CONTRACT_INSTANCE = 20 SCV_LEDGER_KEY_NONCE = 21 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -100,7 +98,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCValType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/sc_vec.py b/stellar_sdk/xdr/sc_vec.py index 37390f08..6ae68a9a 100644 --- a/stellar_sdk/xdr/sc_vec.py +++ b/stellar_sdk/xdr/sc_vec.py @@ -3,35 +3,29 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .sc_val import SCVal - -__all__ = ["SCVec"] - - +__all__ = ['SCVec'] class SCVec: """ XDR Source Code:: typedef SCVal SCVec<>; """ - def __init__(self, sc_vec: List[SCVal]) -> None: _expect_max_length = 4294967295 if sc_vec and len(sc_vec) > _expect_max_length: - raise ValueError( - f"The maximum length of `sc_vec` should be {_expect_max_length}, but got {len(sc_vec)}." - ) + raise ValueError(f"The maximum length of `sc_vec` should be {_expect_max_length}, but got {len(sc_vec)}.") self.sc_vec = sc_vec - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.sc_vec)) for sc_vec_item in self.sc_vec: sc_vec_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCVec: length = unpacker.unpack_uint() @@ -39,7 +33,6 @@ def unpack(cls, unpacker: Unpacker) -> SCVec: for _ in range(length): sc_vec.append(SCVal.unpack(unpacker)) return cls(sc_vec) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,10 +51,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCVec: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.sc_vec) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/scp_ballot.py b/stellar_sdk/xdr/scp_ballot.py index 333b5590..3638578e 100644 --- a/stellar_sdk/xdr/scp_ballot.py +++ b/stellar_sdk/xdr/scp_ballot.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint32 import Uint32 from .value import Value - -__all__ = ["SCPBallot"] - - +__all__ = ['SCPBallot'] class SCPBallot: """ XDR Source Code:: @@ -22,7 +22,6 @@ class SCPBallot: Value value; // x }; """ - def __init__( self, counter: Uint32, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.counter = counter self.value = value - def pack(self, packer: Packer) -> None: self.counter.pack(packer) self.value.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPBallot: counter = Uint32.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPBallot: counter=counter, value=value, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPBallot: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.counter, - self.value, - ) - ) - + return hash((self.counter, self.value,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.counter == other.counter and self.value == other.value - + return self.counter== other.counter and self.value== other.value def __str__(self): out = [ - f"counter={self.counter}", - f"value={self.value}", + f'counter={self.counter}', + f'value={self.value}', ] return f"" diff --git a/stellar_sdk/xdr/scp_envelope.py b/stellar_sdk/xdr/scp_envelope.py index 7460ddba..09e9d2f7 100644 --- a/stellar_sdk/xdr/scp_envelope.py +++ b/stellar_sdk/xdr/scp_envelope.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .scp_statement import SCPStatement from .signature import Signature - -__all__ = ["SCPEnvelope"] - - +__all__ = ['SCPEnvelope'] class SCPEnvelope: """ XDR Source Code:: @@ -22,7 +22,6 @@ class SCPEnvelope: Signature signature; }; """ - def __init__( self, statement: SCPStatement, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.statement = statement self.signature = signature - def pack(self, packer: Packer) -> None: self.statement.pack(packer) self.signature.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPEnvelope: statement = SCPStatement.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPEnvelope: statement=statement, signature=signature, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPEnvelope: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.statement, - self.signature, - ) - ) - + return hash((self.statement, self.signature,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.statement == other.statement and self.signature == other.signature - + return self.statement== other.statement and self.signature== other.signature def __str__(self): out = [ - f"statement={self.statement}", - f"signature={self.signature}", + f'statement={self.statement}', + f'signature={self.signature}', ] return f"" diff --git a/stellar_sdk/xdr/scp_history_entry.py b/stellar_sdk/xdr/scp_history_entry.py index 69d2a89b..bb5ea2f6 100644 --- a/stellar_sdk/xdr/scp_history_entry.py +++ b/stellar_sdk/xdr/scp_history_entry.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .scp_history_entry_v0 import SCPHistoryEntryV0 - -__all__ = ["SCPHistoryEntry"] - - +__all__ = ['SCPHistoryEntry'] class SCPHistoryEntry: """ XDR Source Code:: @@ -22,7 +21,6 @@ class SCPHistoryEntry: SCPHistoryEntryV0 v0; }; """ - def __init__( self, v: int, @@ -30,7 +28,6 @@ def __init__( ) -> None: self.v = v self.v0 = v0 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -38,7 +35,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v0 should not be None.") self.v0.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPHistoryEntry: v = Integer.unpack(unpacker) @@ -46,7 +42,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPHistoryEntry: v0 = SCPHistoryEntryV0.unpack(unpacker) return cls(v=v, v0=v0) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -65,22 +60,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPHistoryEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v0, - ) - ) - + return hash((self.v, self.v0,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v0 == other.v0 - + return self.v== other.v and self.v0== other.v0 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v0={self.v0}") if self.v0 is not None else None + out.append(f'v={self.v}') + out.append(f'v0={self.v0}') if self.v0 is not None else None return f"" diff --git a/stellar_sdk/xdr/scp_history_entry_v0.py b/stellar_sdk/xdr/scp_history_entry_v0.py index a93e64bf..6da1ae46 100644 --- a/stellar_sdk/xdr/scp_history_entry_v0.py +++ b/stellar_sdk/xdr/scp_history_entry_v0.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .ledger_scp_messages import LedgerSCPMessages from .scp_quorum_set import SCPQuorumSet - -__all__ = ["SCPHistoryEntryV0"] - - +from .ledger_scp_messages import LedgerSCPMessages +__all__ = ['SCPHistoryEntryV0'] class SCPHistoryEntryV0: """ XDR Source Code:: @@ -23,7 +22,6 @@ class SCPHistoryEntryV0: LedgerSCPMessages ledgerMessages; }; """ - def __init__( self, quorum_sets: List[SCPQuorumSet], @@ -31,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if quorum_sets and len(quorum_sets) > _expect_max_length: - raise ValueError( - f"The maximum length of `quorum_sets` should be {_expect_max_length}, but got {len(quorum_sets)}." - ) + raise ValueError(f"The maximum length of `quorum_sets` should be {_expect_max_length}, but got {len(quorum_sets)}.") self.quorum_sets = quorum_sets self.ledger_messages = ledger_messages - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.quorum_sets)) for quorum_sets_item in self.quorum_sets: quorum_sets_item.pack(packer) self.ledger_messages.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPHistoryEntryV0: length = unpacker.unpack_uint() @@ -54,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPHistoryEntryV0: quorum_sets=quorum_sets, ledger_messages=ledger_messages, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,26 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPHistoryEntryV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.quorum_sets, - self.ledger_messages, - ) - ) - + return hash((self.quorum_sets, self.ledger_messages,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.quorum_sets == other.quorum_sets - and self.ledger_messages == other.ledger_messages - ) - + return self.quorum_sets== other.quorum_sets and self.ledger_messages== other.ledger_messages def __str__(self): out = [ - f"quorum_sets={self.quorum_sets}", - f"ledger_messages={self.ledger_messages}", + f'quorum_sets={self.quorum_sets}', + f'ledger_messages={self.ledger_messages}', ] return f"" diff --git a/stellar_sdk/xdr/scp_nomination.py b/stellar_sdk/xdr/scp_nomination.py index 8147ec7d..c470a538 100644 --- a/stellar_sdk/xdr/scp_nomination.py +++ b/stellar_sdk/xdr/scp_nomination.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash from .value import Value - -__all__ = ["SCPNomination"] - - +from .value import Value +__all__ = ['SCPNomination'] class SCPNomination: """ XDR Source Code:: @@ -24,7 +24,6 @@ class SCPNomination: Value accepted<>; // Y }; """ - def __init__( self, quorum_set_hash: Hash, @@ -33,18 +32,13 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if votes and len(votes) > _expect_max_length: - raise ValueError( - f"The maximum length of `votes` should be {_expect_max_length}, but got {len(votes)}." - ) + raise ValueError(f"The maximum length of `votes` should be {_expect_max_length}, but got {len(votes)}.") _expect_max_length = 4294967295 if accepted and len(accepted) > _expect_max_length: - raise ValueError( - f"The maximum length of `accepted` should be {_expect_max_length}, but got {len(accepted)}." - ) + raise ValueError(f"The maximum length of `accepted` should be {_expect_max_length}, but got {len(accepted)}.") self.quorum_set_hash = quorum_set_hash self.votes = votes self.accepted = accepted - def pack(self, packer: Packer) -> None: self.quorum_set_hash.pack(packer) packer.pack_uint(len(self.votes)) @@ -53,7 +47,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.accepted)) for accepted_item in self.accepted: accepted_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPNomination: quorum_set_hash = Hash.unpack(unpacker) @@ -70,7 +63,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPNomination: votes=votes, accepted=accepted, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -89,29 +81,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPNomination: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.quorum_set_hash, - self.votes, - self.accepted, - ) - ) - + return hash((self.quorum_set_hash, self.votes, self.accepted,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.quorum_set_hash == other.quorum_set_hash - and self.votes == other.votes - and self.accepted == other.accepted - ) - + return self.quorum_set_hash== other.quorum_set_hash and self.votes== other.votes and self.accepted== other.accepted def __str__(self): out = [ - f"quorum_set_hash={self.quorum_set_hash}", - f"votes={self.votes}", - f"accepted={self.accepted}", + f'quorum_set_hash={self.quorum_set_hash}', + f'votes={self.votes}', + f'accepted={self.accepted}', ] return f"" diff --git a/stellar_sdk/xdr/scp_quorum_set.py b/stellar_sdk/xdr/scp_quorum_set.py index 87f6298b..3dc58ce5 100644 --- a/stellar_sdk/xdr/scp_quorum_set.py +++ b/stellar_sdk/xdr/scp_quorum_set.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .node_id import NodeID from .uint32 import Uint32 - -__all__ = ["SCPQuorumSet"] - - +from .node_id import NodeID +__all__ = ['SCPQuorumSet'] class SCPQuorumSet: """ XDR Source Code:: @@ -24,7 +23,6 @@ class SCPQuorumSet: SCPQuorumSet innerSets<>; }; """ - def __init__( self, threshold: Uint32, @@ -33,18 +31,13 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if validators and len(validators) > _expect_max_length: - raise ValueError( - f"The maximum length of `validators` should be {_expect_max_length}, but got {len(validators)}." - ) + raise ValueError(f"The maximum length of `validators` should be {_expect_max_length}, but got {len(validators)}.") _expect_max_length = 4294967295 if inner_sets and len(inner_sets) > _expect_max_length: - raise ValueError( - f"The maximum length of `inner_sets` should be {_expect_max_length}, but got {len(inner_sets)}." - ) + raise ValueError(f"The maximum length of `inner_sets` should be {_expect_max_length}, but got {len(inner_sets)}.") self.threshold = threshold self.validators = validators self.inner_sets = inner_sets - def pack(self, packer: Packer) -> None: self.threshold.pack(packer) packer.pack_uint(len(self.validators)) @@ -53,7 +46,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.inner_sets)) for inner_sets_item in self.inner_sets: inner_sets_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPQuorumSet: threshold = Uint32.unpack(unpacker) @@ -70,7 +62,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPQuorumSet: validators=validators, inner_sets=inner_sets, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -89,29 +80,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPQuorumSet: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.threshold, - self.validators, - self.inner_sets, - ) - ) - + return hash((self.threshold, self.validators, self.inner_sets,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.threshold == other.threshold - and self.validators == other.validators - and self.inner_sets == other.inner_sets - ) - + return self.threshold== other.threshold and self.validators== other.validators and self.inner_sets== other.inner_sets def __str__(self): out = [ - f"threshold={self.threshold}", - f"validators={self.validators}", - f"inner_sets={self.inner_sets}", + f'threshold={self.threshold}', + f'validators={self.validators}', + f'inner_sets={self.inner_sets}', ] return f"" diff --git a/stellar_sdk/xdr/scp_statement.py b/stellar_sdk/xdr/scp_statement.py index 8316c1cf..9b463d03 100644 --- a/stellar_sdk/xdr/scp_statement.py +++ b/stellar_sdk/xdr/scp_statement.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .node_id import NodeID -from .scp_statement_pledges import SCPStatementPledges from .uint64 import Uint64 - -__all__ = ["SCPStatement"] - - +from .scp_statement_pledges import SCPStatementPledges +__all__ = ['SCPStatement'] class SCPStatement: """ XDR Source Code:: @@ -56,7 +56,6 @@ class SCPStatement: pledges; }; """ - def __init__( self, node_id: NodeID, @@ -66,12 +65,10 @@ def __init__( self.node_id = node_id self.slot_index = slot_index self.pledges = pledges - def pack(self, packer: Packer) -> None: self.node_id.pack(packer) self.slot_index.pack(packer) self.pledges.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPStatement: node_id = NodeID.unpack(unpacker) @@ -82,7 +79,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPStatement: slot_index=slot_index, pledges=pledges, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -101,29 +97,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPStatement: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.node_id, - self.slot_index, - self.pledges, - ) - ) - + return hash((self.node_id, self.slot_index, self.pledges,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.node_id == other.node_id - and self.slot_index == other.slot_index - and self.pledges == other.pledges - ) - + return self.node_id== other.node_id and self.slot_index== other.slot_index and self.pledges== other.pledges def __str__(self): out = [ - f"node_id={self.node_id}", - f"slot_index={self.slot_index}", - f"pledges={self.pledges}", + f'node_id={self.node_id}', + f'slot_index={self.slot_index}', + f'pledges={self.pledges}', ] return f"" diff --git a/stellar_sdk/xdr/scp_statement_confirm.py b/stellar_sdk/xdr/scp_statement_confirm.py index 001524a9..9d419d75 100644 --- a/stellar_sdk/xdr/scp_statement_confirm.py +++ b/stellar_sdk/xdr/scp_statement_confirm.py @@ -3,16 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .hash import Hash from .scp_ballot import SCPBallot from .uint32 import Uint32 - -__all__ = ["SCPStatementConfirm"] - - +from .uint32 import Uint32 +from .uint32 import Uint32 +from .hash import Hash +__all__ = ['SCPStatementConfirm'] class SCPStatementConfirm: """ XDR Source Code:: @@ -26,7 +28,6 @@ class SCPStatementConfirm: Hash quorumSetHash; // D } """ - def __init__( self, ballot: SCPBallot, @@ -40,14 +41,12 @@ def __init__( self.n_commit = n_commit self.n_h = n_h self.quorum_set_hash = quorum_set_hash - def pack(self, packer: Packer) -> None: self.ballot.pack(packer) self.n_prepared.pack(packer) self.n_commit.pack(packer) self.n_h.pack(packer) self.quorum_set_hash.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPStatementConfirm: ballot = SCPBallot.unpack(unpacker) @@ -62,7 +61,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPStatementConfirm: n_h=n_h, quorum_set_hash=quorum_set_hash, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -81,35 +79,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPStatementConfirm: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ballot, - self.n_prepared, - self.n_commit, - self.n_h, - self.quorum_set_hash, - ) - ) - + return hash((self.ballot, self.n_prepared, self.n_commit, self.n_h, self.quorum_set_hash,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ballot == other.ballot - and self.n_prepared == other.n_prepared - and self.n_commit == other.n_commit - and self.n_h == other.n_h - and self.quorum_set_hash == other.quorum_set_hash - ) - + return self.ballot== other.ballot and self.n_prepared== other.n_prepared and self.n_commit== other.n_commit and self.n_h== other.n_h and self.quorum_set_hash== other.quorum_set_hash def __str__(self): out = [ - f"ballot={self.ballot}", - f"n_prepared={self.n_prepared}", - f"n_commit={self.n_commit}", - f"n_h={self.n_h}", - f"quorum_set_hash={self.quorum_set_hash}", + f'ballot={self.ballot}', + f'n_prepared={self.n_prepared}', + f'n_commit={self.n_commit}', + f'n_h={self.n_h}', + f'quorum_set_hash={self.quorum_set_hash}', ] return f"" diff --git a/stellar_sdk/xdr/scp_statement_externalize.py b/stellar_sdk/xdr/scp_statement_externalize.py index f2ab8a2c..c788892d 100644 --- a/stellar_sdk/xdr/scp_statement_externalize.py +++ b/stellar_sdk/xdr/scp_statement_externalize.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .hash import Hash from .scp_ballot import SCPBallot from .uint32 import Uint32 - -__all__ = ["SCPStatementExternalize"] - - +from .hash import Hash +__all__ = ['SCPStatementExternalize'] class SCPStatementExternalize: """ XDR Source Code:: @@ -24,7 +24,6 @@ class SCPStatementExternalize: Hash commitQuorumSetHash; // D used before EXTERNALIZE } """ - def __init__( self, commit: SCPBallot, @@ -34,12 +33,10 @@ def __init__( self.commit = commit self.n_h = n_h self.commit_quorum_set_hash = commit_quorum_set_hash - def pack(self, packer: Packer) -> None: self.commit.pack(packer) self.n_h.pack(packer) self.commit_quorum_set_hash.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPStatementExternalize: commit = SCPBallot.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPStatementExternalize: n_h=n_h, commit_quorum_set_hash=commit_quorum_set_hash, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPStatementExternalize: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.commit, - self.n_h, - self.commit_quorum_set_hash, - ) - ) - + return hash((self.commit, self.n_h, self.commit_quorum_set_hash,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.commit == other.commit - and self.n_h == other.n_h - and self.commit_quorum_set_hash == other.commit_quorum_set_hash - ) - + return self.commit== other.commit and self.n_h== other.n_h and self.commit_quorum_set_hash== other.commit_quorum_set_hash def __str__(self): out = [ - f"commit={self.commit}", - f"n_h={self.n_h}", - f"commit_quorum_set_hash={self.commit_quorum_set_hash}", + f'commit={self.commit}', + f'n_h={self.n_h}', + f'commit_quorum_set_hash={self.commit_quorum_set_hash}', ] return f"" diff --git a/stellar_sdk/xdr/scp_statement_pledges.py b/stellar_sdk/xdr/scp_statement_pledges.py index 6add9bed..7bb69435 100644 --- a/stellar_sdk/xdr/scp_statement_pledges.py +++ b/stellar_sdk/xdr/scp_statement_pledges.py @@ -3,18 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .scp_nomination import SCPNomination +from .scp_statement_type import SCPStatementType +from .scp_statement_prepare import SCPStatementPrepare from .scp_statement_confirm import SCPStatementConfirm from .scp_statement_externalize import SCPStatementExternalize -from .scp_statement_prepare import SCPStatementPrepare -from .scp_statement_type import SCPStatementType - -__all__ = ["SCPStatementPledges"] - - +from .scp_nomination import SCPNomination +__all__ = ['SCPStatementPledges'] class SCPStatementPledges: """ XDR Source Code:: @@ -51,7 +51,6 @@ class SCPStatementPledges: SCPNomination nominate; } """ - def __init__( self, type: SCPStatementType, @@ -65,7 +64,6 @@ def __init__( self.confirm = confirm self.externalize = externalize self.nominate = nominate - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == SCPStatementType.SCP_ST_PREPARE: @@ -88,7 +86,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("nominate should not be None.") self.nominate.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPStatementPledges: type = SCPStatementType.unpack(unpacker) @@ -105,7 +102,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPStatementPledges: nominate = SCPNomination.unpack(unpacker) return cls(type=type, nominate=nominate) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -124,36 +120,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPStatementPledges: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.prepare, - self.confirm, - self.externalize, - self.nominate, - ) - ) - + return hash((self.type, self.prepare, self.confirm, self.externalize, self.nominate,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.prepare == other.prepare - and self.confirm == other.confirm - and self.externalize == other.externalize - and self.nominate == other.nominate - ) - + return self.type== other.type and self.prepare== other.prepare and self.confirm== other.confirm and self.externalize== other.externalize and self.nominate== other.nominate def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"prepare={self.prepare}") if self.prepare is not None else None - out.append(f"confirm={self.confirm}") if self.confirm is not None else None - out.append( - f"externalize={self.externalize}" - ) if self.externalize is not None else None - out.append(f"nominate={self.nominate}") if self.nominate is not None else None + out.append(f'type={self.type}') + out.append(f'prepare={self.prepare}') if self.prepare is not None else None + out.append(f'confirm={self.confirm}') if self.confirm is not None else None + out.append(f'externalize={self.externalize}') if self.externalize is not None else None + out.append(f'nominate={self.nominate}') if self.nominate is not None else None return f"" diff --git a/stellar_sdk/xdr/scp_statement_prepare.py b/stellar_sdk/xdr/scp_statement_prepare.py index ef997f0f..c865c887 100644 --- a/stellar_sdk/xdr/scp_statement_prepare.py +++ b/stellar_sdk/xdr/scp_statement_prepare.py @@ -3,17 +3,19 @@ from __future__ import annotations import base64 -from typing import Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash from .scp_ballot import SCPBallot +from .scp_ballot import SCPBallot +from .scp_ballot import SCPBallot from .uint32 import Uint32 - -__all__ = ["SCPStatementPrepare"] - - +from .uint32 import Uint32 +__all__ = ['SCPStatementPrepare'] class SCPStatementPrepare: """ XDR Source Code:: @@ -28,7 +30,6 @@ class SCPStatementPrepare: uint32 nH; // h.n } """ - def __init__( self, quorum_set_hash: Hash, @@ -44,7 +45,6 @@ def __init__( self.prepared_prime = prepared_prime self.n_c = n_c self.n_h = n_h - def pack(self, packer: Packer) -> None: self.quorum_set_hash.pack(packer) self.ballot.pack(packer) @@ -60,7 +60,6 @@ def pack(self, packer: Packer) -> None: self.prepared_prime.pack(packer) self.n_c.pack(packer) self.n_h.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SCPStatementPrepare: quorum_set_hash = Hash.unpack(unpacker) @@ -77,7 +76,6 @@ def unpack(cls, unpacker: Unpacker) -> SCPStatementPrepare: n_c=n_c, n_h=n_h, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -96,38 +94,19 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SCPStatementPrepare: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.quorum_set_hash, - self.ballot, - self.prepared, - self.prepared_prime, - self.n_c, - self.n_h, - ) - ) - + return hash((self.quorum_set_hash, self.ballot, self.prepared, self.prepared_prime, self.n_c, self.n_h,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.quorum_set_hash == other.quorum_set_hash - and self.ballot == other.ballot - and self.prepared == other.prepared - and self.prepared_prime == other.prepared_prime - and self.n_c == other.n_c - and self.n_h == other.n_h - ) - + return self.quorum_set_hash== other.quorum_set_hash and self.ballot== other.ballot and self.prepared== other.prepared and self.prepared_prime== other.prepared_prime and self.n_c== other.n_c and self.n_h== other.n_h def __str__(self): out = [ - f"quorum_set_hash={self.quorum_set_hash}", - f"ballot={self.ballot}", - f"prepared={self.prepared}", - f"prepared_prime={self.prepared_prime}", - f"n_c={self.n_c}", - f"n_h={self.n_h}", + f'quorum_set_hash={self.quorum_set_hash}', + f'ballot={self.ballot}', + f'prepared={self.prepared}', + f'prepared_prime={self.prepared_prime}', + f'n_c={self.n_c}', + f'n_h={self.n_h}', ] return f"" diff --git a/stellar_sdk/xdr/scp_statement_type.py b/stellar_sdk/xdr/scp_statement_type.py index ed005111..b15f81d8 100644 --- a/stellar_sdk/xdr/scp_statement_type.py +++ b/stellar_sdk/xdr/scp_statement_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SCPStatementType"] - - +__all__ = ['SCPStatementType'] class SCPStatementType(IntEnum): """ XDR Source Code:: @@ -22,12 +22,10 @@ class SCPStatementType(IntEnum): SCP_ST_NOMINATE = 3 }; """ - SCP_ST_PREPARE = 0 SCP_ST_CONFIRM = 1 SCP_ST_EXTERNALIZE = 2 SCP_ST_NOMINATE = 3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -35,7 +33,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SCPStatementType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/send_more.py b/stellar_sdk/xdr/send_more.py index 58093dd7..225b516a 100644 --- a/stellar_sdk/xdr/send_more.py +++ b/stellar_sdk/xdr/send_more.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint32 import Uint32 - -__all__ = ["SendMore"] - - +__all__ = ['SendMore'] class SendMore: """ XDR Source Code:: @@ -20,23 +20,19 @@ class SendMore: uint32 numMessages; }; """ - def __init__( self, num_messages: Uint32, ) -> None: self.num_messages = num_messages - def pack(self, packer: Packer) -> None: self.num_messages.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SendMore: num_messages = Uint32.unpack(unpacker) return cls( num_messages=num_messages, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -55,17 +51,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SendMore: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.num_messages,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.num_messages == other.num_messages - + return self.num_messages== other.num_messages def __str__(self): out = [ - f"num_messages={self.num_messages}", + f'num_messages={self.num_messages}', ] return f"" diff --git a/stellar_sdk/xdr/send_more_extended.py b/stellar_sdk/xdr/send_more_extended.py index 8cd5b7ce..1082b361 100644 --- a/stellar_sdk/xdr/send_more_extended.py +++ b/stellar_sdk/xdr/send_more_extended.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint32 import Uint32 - -__all__ = ["SendMoreExtended"] - - +from .uint32 import Uint32 +__all__ = ['SendMoreExtended'] class SendMoreExtended: """ XDR Source Code:: @@ -21,7 +22,6 @@ class SendMoreExtended: uint32 numBytes; }; """ - def __init__( self, num_messages: Uint32, @@ -29,11 +29,9 @@ def __init__( ) -> None: self.num_messages = num_messages self.num_bytes = num_bytes - def pack(self, packer: Packer) -> None: self.num_messages.pack(packer) self.num_bytes.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SendMoreExtended: num_messages = Uint32.unpack(unpacker) @@ -42,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SendMoreExtended: num_messages=num_messages, num_bytes=num_bytes, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SendMoreExtended: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.num_messages, - self.num_bytes, - ) - ) - + return hash((self.num_messages, self.num_bytes,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.num_messages == other.num_messages - and self.num_bytes == other.num_bytes - ) - + return self.num_messages== other.num_messages and self.num_bytes== other.num_bytes def __str__(self): out = [ - f"num_messages={self.num_messages}", - f"num_bytes={self.num_bytes}", + f'num_messages={self.num_messages}', + f'num_bytes={self.num_bytes}', ] return f"" diff --git a/stellar_sdk/xdr/sequence_number.py b/stellar_sdk/xdr/sequence_number.py index e06b3f6d..33845d23 100644 --- a/stellar_sdk/xdr/sequence_number.py +++ b/stellar_sdk/xdr/sequence_number.py @@ -3,32 +3,28 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int64 import Int64 - -__all__ = ["SequenceNumber"] - - +__all__ = ['SequenceNumber'] class SequenceNumber: """ XDR Source Code:: typedef int64 SequenceNumber; """ - def __init__(self, sequence_number: Int64) -> None: self.sequence_number = sequence_number - def pack(self, packer: Packer) -> None: self.sequence_number.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SequenceNumber: sequence_number = Int64.unpack(unpacker) return cls(sequence_number) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +43,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SequenceNumber: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.sequence_number) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/set_options_op.py b/stellar_sdk/xdr/set_options_op.py index 84696d3f..6b2de23e 100644 --- a/stellar_sdk/xdr/set_options_op.py +++ b/stellar_sdk/xdr/set_options_op.py @@ -3,18 +3,22 @@ from __future__ import annotations import base64 -from typing import Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID -from .signer import Signer -from .string32 import String32 from .uint32 import Uint32 - -__all__ = ["SetOptionsOp"] - - +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .string32 import String32 +from .signer import Signer +__all__ = ['SetOptionsOp'] class SetOptionsOp: """ XDR Source Code:: @@ -39,7 +43,6 @@ class SetOptionsOp: Signer* signer; }; """ - def __init__( self, inflation_dest: Optional[AccountID], @@ -61,7 +64,6 @@ def __init__( self.high_threshold = high_threshold self.home_domain = home_domain self.signer = signer - def pack(self, packer: Packer) -> None: if self.inflation_dest is None: packer.pack_uint(0) @@ -108,7 +110,6 @@ def pack(self, packer: Packer) -> None: else: packer.pack_uint(1) self.signer.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SetOptionsOp: inflation_dest = AccountID.unpack(unpacker) if unpacker.unpack_uint() else None @@ -131,7 +132,6 @@ def unpack(cls, unpacker: Unpacker) -> SetOptionsOp: home_domain=home_domain, signer=signer, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -150,47 +150,22 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SetOptionsOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.inflation_dest, - self.clear_flags, - self.set_flags, - self.master_weight, - self.low_threshold, - self.med_threshold, - self.high_threshold, - self.home_domain, - self.signer, - ) - ) - + return hash((self.inflation_dest, self.clear_flags, self.set_flags, self.master_weight, self.low_threshold, self.med_threshold, self.high_threshold, self.home_domain, self.signer,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.inflation_dest == other.inflation_dest - and self.clear_flags == other.clear_flags - and self.set_flags == other.set_flags - and self.master_weight == other.master_weight - and self.low_threshold == other.low_threshold - and self.med_threshold == other.med_threshold - and self.high_threshold == other.high_threshold - and self.home_domain == other.home_domain - and self.signer == other.signer - ) - + return self.inflation_dest== other.inflation_dest and self.clear_flags== other.clear_flags and self.set_flags== other.set_flags and self.master_weight== other.master_weight and self.low_threshold== other.low_threshold and self.med_threshold== other.med_threshold and self.high_threshold== other.high_threshold and self.home_domain== other.home_domain and self.signer== other.signer def __str__(self): out = [ - f"inflation_dest={self.inflation_dest}", - f"clear_flags={self.clear_flags}", - f"set_flags={self.set_flags}", - f"master_weight={self.master_weight}", - f"low_threshold={self.low_threshold}", - f"med_threshold={self.med_threshold}", - f"high_threshold={self.high_threshold}", - f"home_domain={self.home_domain}", - f"signer={self.signer}", + f'inflation_dest={self.inflation_dest}', + f'clear_flags={self.clear_flags}', + f'set_flags={self.set_flags}', + f'master_weight={self.master_weight}', + f'low_threshold={self.low_threshold}', + f'med_threshold={self.med_threshold}', + f'high_threshold={self.high_threshold}', + f'home_domain={self.home_domain}', + f'signer={self.signer}', ] return f"" diff --git a/stellar_sdk/xdr/set_options_result.py b/stellar_sdk/xdr/set_options_result.py index e32eb77d..7601d17a 100644 --- a/stellar_sdk/xdr/set_options_result.py +++ b/stellar_sdk/xdr/set_options_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .set_options_result_code import SetOptionsResultCode - -__all__ = ["SetOptionsResult"] - - +__all__ = ['SetOptionsResult'] class SetOptionsResult: """ XDR Source Code:: @@ -32,13 +32,11 @@ class SetOptionsResult: void; }; """ - def __init__( self, code: SetOptionsResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == SetOptionsResultCode.SET_OPTIONS_SUCCESS: @@ -63,7 +61,6 @@ def pack(self, packer: Packer) -> None: return if self.code == SetOptionsResultCode.SET_OPTIONS_AUTH_REVOCABLE_REQUIRED: return - @classmethod def unpack(cls, unpacker: Unpacker) -> SetOptionsResult: code = SetOptionsResultCode.unpack(unpacker) @@ -90,7 +87,6 @@ def unpack(cls, unpacker: Unpacker) -> SetOptionsResult: if code == SetOptionsResultCode.SET_OPTIONS_AUTH_REVOCABLE_REQUIRED: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -109,16 +105,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SetOptionsResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/set_options_result_code.py b/stellar_sdk/xdr/set_options_result_code.py index e89e8e19..73f1a5f6 100644 --- a/stellar_sdk/xdr/set_options_result_code.py +++ b/stellar_sdk/xdr/set_options_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SetOptionsResultCode"] - - +__all__ = ['SetOptionsResultCode'] class SetOptionsResultCode(IntEnum): """ XDR Source Code:: @@ -32,7 +32,6 @@ class SetOptionsResultCode(IntEnum): -10 // auth revocable is required for clawback }; """ - SET_OPTIONS_SUCCESS = 0 SET_OPTIONS_LOW_RESERVE = -1 SET_OPTIONS_TOO_MANY_SIGNERS = -2 @@ -44,7 +43,6 @@ class SetOptionsResultCode(IntEnum): SET_OPTIONS_BAD_SIGNER = -8 SET_OPTIONS_INVALID_HOME_DOMAIN = -9 SET_OPTIONS_AUTH_REVOCABLE_REQUIRED = -10 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -52,7 +50,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SetOptionsResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/set_trust_line_flags_op.py b/stellar_sdk/xdr/set_trust_line_flags_op.py index 3ecac851..7c3cc54c 100644 --- a/stellar_sdk/xdr/set_trust_line_flags_op.py +++ b/stellar_sdk/xdr/set_trust_line_flags_op.py @@ -3,16 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .asset import Asset from .uint32 import Uint32 - -__all__ = ["SetTrustLineFlagsOp"] - - +from .uint32 import Uint32 +__all__ = ['SetTrustLineFlagsOp'] class SetTrustLineFlagsOp: """ XDR Source Code:: @@ -26,7 +27,6 @@ class SetTrustLineFlagsOp: uint32 setFlags; // which flags to set }; """ - def __init__( self, trustor: AccountID, @@ -38,13 +38,11 @@ def __init__( self.asset = asset self.clear_flags = clear_flags self.set_flags = set_flags - def pack(self, packer: Packer) -> None: self.trustor.pack(packer) self.asset.pack(packer) self.clear_flags.pack(packer) self.set_flags.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SetTrustLineFlagsOp: trustor = AccountID.unpack(unpacker) @@ -57,7 +55,6 @@ def unpack(cls, unpacker: Unpacker) -> SetTrustLineFlagsOp: clear_flags=clear_flags, set_flags=set_flags, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -76,32 +73,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SetTrustLineFlagsOp: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.trustor, - self.asset, - self.clear_flags, - self.set_flags, - ) - ) - + return hash((self.trustor, self.asset, self.clear_flags, self.set_flags,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.trustor == other.trustor - and self.asset == other.asset - and self.clear_flags == other.clear_flags - and self.set_flags == other.set_flags - ) - + return self.trustor== other.trustor and self.asset== other.asset and self.clear_flags== other.clear_flags and self.set_flags== other.set_flags def __str__(self): out = [ - f"trustor={self.trustor}", - f"asset={self.asset}", - f"clear_flags={self.clear_flags}", - f"set_flags={self.set_flags}", + f'trustor={self.trustor}', + f'asset={self.asset}', + f'clear_flags={self.clear_flags}', + f'set_flags={self.set_flags}', ] return f"" diff --git a/stellar_sdk/xdr/set_trust_line_flags_result.py b/stellar_sdk/xdr/set_trust_line_flags_result.py index e38ab34b..d6b81724 100644 --- a/stellar_sdk/xdr/set_trust_line_flags_result.py +++ b/stellar_sdk/xdr/set_trust_line_flags_result.py @@ -3,14 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .set_trust_line_flags_result_code import SetTrustLineFlagsResultCode - -__all__ = ["SetTrustLineFlagsResult"] - - +__all__ = ['SetTrustLineFlagsResult'] class SetTrustLineFlagsResult: """ XDR Source Code:: @@ -27,13 +27,11 @@ class SetTrustLineFlagsResult: void; }; """ - def __init__( self, code: SetTrustLineFlagsResultCode, ) -> None: self.code = code - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == SetTrustLineFlagsResultCode.SET_TRUST_LINE_FLAGS_SUCCESS: @@ -48,7 +46,6 @@ def pack(self, packer: Packer) -> None: return if self.code == SetTrustLineFlagsResultCode.SET_TRUST_LINE_FLAGS_LOW_RESERVE: return - @classmethod def unpack(cls, unpacker: Unpacker) -> SetTrustLineFlagsResult: code = SetTrustLineFlagsResultCode.unpack(unpacker) @@ -65,7 +62,6 @@ def unpack(cls, unpacker: Unpacker) -> SetTrustLineFlagsResult: if code == SetTrustLineFlagsResultCode.SET_TRUST_LINE_FLAGS_LOW_RESERVE: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -84,16 +80,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SetTrustLineFlagsResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.code,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.code == other.code - + return self.code== other.code def __str__(self): out = [] - out.append(f"code={self.code}") + out.append(f'code={self.code}') return f"" diff --git a/stellar_sdk/xdr/set_trust_line_flags_result_code.py b/stellar_sdk/xdr/set_trust_line_flags_result_code.py index 02b3a1fb..11f6c071 100644 --- a/stellar_sdk/xdr/set_trust_line_flags_result_code.py +++ b/stellar_sdk/xdr/set_trust_line_flags_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SetTrustLineFlagsResultCode"] - - +__all__ = ['SetTrustLineFlagsResultCode'] class SetTrustLineFlagsResultCode(IntEnum): """ XDR Source Code:: @@ -28,14 +28,12 @@ class SetTrustLineFlagsResultCode(IntEnum): // on revoke due to low reserves }; """ - SET_TRUST_LINE_FLAGS_SUCCESS = 0 SET_TRUST_LINE_FLAGS_MALFORMED = -1 SET_TRUST_LINE_FLAGS_NO_TRUST_LINE = -2 SET_TRUST_LINE_FLAGS_CANT_REVOKE = -3 SET_TRUST_LINE_FLAGS_INVALID_STATE = -4 SET_TRUST_LINE_FLAGS_LOW_RESERVE = -5 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -43,7 +41,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SetTrustLineFlagsResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/signature.py b/stellar_sdk/xdr/signature.py index 7a52fce8..9e8373d9 100644 --- a/stellar_sdk/xdr/signature.py +++ b/stellar_sdk/xdr/signature.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["Signature"] - - +__all__ = ['Signature'] class Signature: """ XDR Source Code:: typedef opaque Signature<64>; """ - def __init__(self, signature: bytes) -> None: self.signature = signature - def pack(self, packer: Packer) -> None: Opaque(self.signature, 64, False).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Signature: signature = Opaque.unpack(unpacker, 64, False) return cls(signature) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Signature: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.signature) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/signature_hint.py b/stellar_sdk/xdr/signature_hint.py index 482db43b..86011bd3 100644 --- a/stellar_sdk/xdr/signature_hint.py +++ b/stellar_sdk/xdr/signature_hint.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["SignatureHint"] - - +__all__ = ['SignatureHint'] class SignatureHint: """ XDR Source Code:: typedef opaque SignatureHint[4]; """ - def __init__(self, signature_hint: bytes) -> None: self.signature_hint = signature_hint - def pack(self, packer: Packer) -> None: Opaque(self.signature_hint, 4, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SignatureHint: signature_hint = Opaque.unpack(unpacker, 4, True) return cls(signature_hint) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SignatureHint: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.signature_hint) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/signed_survey_request_message.py b/stellar_sdk/xdr/signed_survey_request_message.py index 66d7cefb..c5eb4b9e 100644 --- a/stellar_sdk/xdr/signed_survey_request_message.py +++ b/stellar_sdk/xdr/signed_survey_request_message.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .signature import Signature from .survey_request_message import SurveyRequestMessage - -__all__ = ["SignedSurveyRequestMessage"] - - +__all__ = ['SignedSurveyRequestMessage'] class SignedSurveyRequestMessage: """ XDR Source Code:: @@ -22,7 +22,6 @@ class SignedSurveyRequestMessage: SurveyRequestMessage request; }; """ - def __init__( self, request_signature: Signature, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.request_signature = request_signature self.request = request - def pack(self, packer: Packer) -> None: self.request_signature.pack(packer) self.request.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SignedSurveyRequestMessage: request_signature = Signature.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SignedSurveyRequestMessage: request_signature=request_signature, request=request, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SignedSurveyRequestMessage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.request_signature, - self.request, - ) - ) - + return hash((self.request_signature, self.request,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.request_signature == other.request_signature - and self.request == other.request - ) - + return self.request_signature== other.request_signature and self.request== other.request def __str__(self): out = [ - f"request_signature={self.request_signature}", - f"request={self.request}", + f'request_signature={self.request_signature}', + f'request={self.request}', ] return f"" diff --git a/stellar_sdk/xdr/signed_survey_response_message.py b/stellar_sdk/xdr/signed_survey_response_message.py index 8a6fa961..e9bae7b2 100644 --- a/stellar_sdk/xdr/signed_survey_response_message.py +++ b/stellar_sdk/xdr/signed_survey_response_message.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .signature import Signature from .survey_response_message import SurveyResponseMessage - -__all__ = ["SignedSurveyResponseMessage"] - - +__all__ = ['SignedSurveyResponseMessage'] class SignedSurveyResponseMessage: """ XDR Source Code:: @@ -22,7 +22,6 @@ class SignedSurveyResponseMessage: SurveyResponseMessage response; }; """ - def __init__( self, response_signature: Signature, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.response_signature = response_signature self.response = response - def pack(self, packer: Packer) -> None: self.response_signature.pack(packer) self.response.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SignedSurveyResponseMessage: response_signature = Signature.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SignedSurveyResponseMessage: response_signature=response_signature, response=response, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SignedSurveyResponseMessage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.response_signature, - self.response, - ) - ) - + return hash((self.response_signature, self.response,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.response_signature == other.response_signature - and self.response == other.response - ) - + return self.response_signature== other.response_signature and self.response== other.response def __str__(self): out = [ - f"response_signature={self.response_signature}", - f"response={self.response}", + f'response_signature={self.response_signature}', + f'response={self.response}', ] return f"" diff --git a/stellar_sdk/xdr/signer.py b/stellar_sdk/xdr/signer.py index 66a0ca12..9421cf8e 100644 --- a/stellar_sdk/xdr/signer.py +++ b/stellar_sdk/xdr/signer.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .signer_key import SignerKey from .uint32 import Uint32 - -__all__ = ["Signer"] - - +__all__ = ['Signer'] class Signer: """ XDR Source Code:: @@ -22,7 +22,6 @@ class Signer: uint32 weight; // really only need 1 byte }; """ - def __init__( self, key: SignerKey, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.key = key self.weight = weight - def pack(self, packer: Packer) -> None: self.key.pack(packer) self.weight.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Signer: key = SignerKey.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> Signer: key=key, weight=weight, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Signer: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.key, - self.weight, - ) - ) - + return hash((self.key, self.weight,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.key == other.key and self.weight == other.weight - + return self.key== other.key and self.weight== other.weight def __str__(self): out = [ - f"key={self.key}", - f"weight={self.weight}", + f'key={self.key}', + f'weight={self.weight}', ] return f"" diff --git a/stellar_sdk/xdr/signer_key.py b/stellar_sdk/xdr/signer_key.py index 9ce1aac4..59db6fdd 100644 --- a/stellar_sdk/xdr/signer_key.py +++ b/stellar_sdk/xdr/signer_key.py @@ -3,16 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .signer_key_ed25519_signed_payload import SignerKeyEd25519SignedPayload from .signer_key_type import SignerKeyType from .uint256 import Uint256 - -__all__ = ["SignerKey"] - - +from .uint256 import Uint256 +from .uint256 import Uint256 +from .signer_key_ed25519_signed_payload import SignerKeyEd25519SignedPayload +__all__ = ['SignerKey'] class SignerKey: """ XDR Source Code:: @@ -37,7 +39,6 @@ class SignerKey: } ed25519SignedPayload; }; """ - def __init__( self, type: SignerKeyType, @@ -51,7 +52,6 @@ def __init__( self.pre_auth_tx = pre_auth_tx self.hash_x = hash_x self.ed25519_signed_payload = ed25519_signed_payload - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == SignerKeyType.SIGNER_KEY_TYPE_ED25519: @@ -74,7 +74,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("ed25519_signed_payload should not be None.") self.ed25519_signed_payload.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SignerKey: type = SignerKeyType.unpack(unpacker) @@ -91,7 +90,6 @@ def unpack(cls, unpacker: Unpacker) -> SignerKey: ed25519_signed_payload = SignerKeyEd25519SignedPayload.unpack(unpacker) return cls(type=type, ed25519_signed_payload=ed25519_signed_payload) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -110,38 +108,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SignerKey: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.ed25519, - self.pre_auth_tx, - self.hash_x, - self.ed25519_signed_payload, - ) - ) - + return hash((self.type, self.ed25519, self.pre_auth_tx, self.hash_x, self.ed25519_signed_payload,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.ed25519 == other.ed25519 - and self.pre_auth_tx == other.pre_auth_tx - and self.hash_x == other.hash_x - and self.ed25519_signed_payload == other.ed25519_signed_payload - ) - + return self.type== other.type and self.ed25519== other.ed25519 and self.pre_auth_tx== other.pre_auth_tx and self.hash_x== other.hash_x and self.ed25519_signed_payload== other.ed25519_signed_payload def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"ed25519={self.ed25519}") if self.ed25519 is not None else None - out.append( - f"pre_auth_tx={self.pre_auth_tx}" - ) if self.pre_auth_tx is not None else None - out.append(f"hash_x={self.hash_x}") if self.hash_x is not None else None - out.append( - f"ed25519_signed_payload={self.ed25519_signed_payload}" - ) if self.ed25519_signed_payload is not None else None + out.append(f'type={self.type}') + out.append(f'ed25519={self.ed25519}') if self.ed25519 is not None else None + out.append(f'pre_auth_tx={self.pre_auth_tx}') if self.pre_auth_tx is not None else None + out.append(f'hash_x={self.hash_x}') if self.hash_x is not None else None + out.append(f'ed25519_signed_payload={self.ed25519_signed_payload}') if self.ed25519_signed_payload is not None else None return f"" diff --git a/stellar_sdk/xdr/signer_key_ed25519_signed_payload.py b/stellar_sdk/xdr/signer_key_ed25519_signed_payload.py index 219b31ee..0de9f865 100644 --- a/stellar_sdk/xdr/signer_key_ed25519_signed_payload.py +++ b/stellar_sdk/xdr/signer_key_ed25519_signed_payload.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque from .uint256 import Uint256 - -__all__ = ["SignerKeyEd25519SignedPayload"] - - +__all__ = ['SignerKeyEd25519SignedPayload'] class SignerKeyEd25519SignedPayload: """ XDR Source Code:: @@ -24,7 +23,6 @@ class SignerKeyEd25519SignedPayload: opaque payload<64>; } """ - def __init__( self, ed25519: Uint256, @@ -32,11 +30,9 @@ def __init__( ) -> None: self.ed25519 = ed25519 self.payload = payload - def pack(self, packer: Packer) -> None: self.ed25519.pack(packer) Opaque(self.payload, 64, False).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SignerKeyEd25519SignedPayload: ed25519 = Uint256.unpack(unpacker) @@ -45,7 +41,6 @@ def unpack(cls, unpacker: Unpacker) -> SignerKeyEd25519SignedPayload: ed25519=ed25519, payload=payload, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -64,23 +59,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SignerKeyEd25519SignedPayload: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ed25519, - self.payload, - ) - ) - + return hash((self.ed25519, self.payload,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.ed25519 == other.ed25519 and self.payload == other.payload - + return self.ed25519== other.ed25519 and self.payload== other.payload def __str__(self): out = [ - f"ed25519={self.ed25519}", - f"payload={self.payload}", + f'ed25519={self.ed25519}', + f'payload={self.payload}', ] return f"" diff --git a/stellar_sdk/xdr/signer_key_type.py b/stellar_sdk/xdr/signer_key_type.py index 3486533e..a12e305f 100644 --- a/stellar_sdk/xdr/signer_key_type.py +++ b/stellar_sdk/xdr/signer_key_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SignerKeyType"] - - +__all__ = ['SignerKeyType'] class SignerKeyType(IntEnum): """ XDR Source Code:: @@ -22,12 +22,10 @@ class SignerKeyType(IntEnum): SIGNER_KEY_TYPE_ED25519_SIGNED_PAYLOAD = KEY_TYPE_ED25519_SIGNED_PAYLOAD }; """ - SIGNER_KEY_TYPE_ED25519 = 0 SIGNER_KEY_TYPE_PRE_AUTH_TX = 1 SIGNER_KEY_TYPE_HASH_X = 2 SIGNER_KEY_TYPE_ED25519_SIGNED_PAYLOAD = 3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -35,7 +33,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SignerKeyType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/simple_payment_result.py b/stellar_sdk/xdr/simple_payment_result.py index 075f948b..4a6595f4 100644 --- a/stellar_sdk/xdr/simple_payment_result.py +++ b/stellar_sdk/xdr/simple_payment_result.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID from .asset import Asset from .int64 import Int64 - -__all__ = ["SimplePaymentResult"] - - +__all__ = ['SimplePaymentResult'] class SimplePaymentResult: """ XDR Source Code:: @@ -24,7 +24,6 @@ class SimplePaymentResult: int64 amount; }; """ - def __init__( self, destination: AccountID, @@ -34,12 +33,10 @@ def __init__( self.destination = destination self.asset = asset self.amount = amount - def pack(self, packer: Packer) -> None: self.destination.pack(packer) self.asset.pack(packer) self.amount.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SimplePaymentResult: destination = AccountID.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> SimplePaymentResult: asset=asset, amount=amount, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SimplePaymentResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.destination, - self.asset, - self.amount, - ) - ) - + return hash((self.destination, self.asset, self.amount,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.destination == other.destination - and self.asset == other.asset - and self.amount == other.amount - ) - + return self.destination== other.destination and self.asset== other.asset and self.amount== other.amount def __str__(self): out = [ - f"destination={self.destination}", - f"asset={self.asset}", - f"amount={self.amount}", + f'destination={self.destination}', + f'asset={self.asset}', + f'amount={self.amount}', ] return f"" diff --git a/stellar_sdk/xdr/soroban_address_credentials.py b/stellar_sdk/xdr/soroban_address_credentials.py index 17a7c445..779c1fc7 100644 --- a/stellar_sdk/xdr/soroban_address_credentials.py +++ b/stellar_sdk/xdr/soroban_address_credentials.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .int64 import Int64 from .sc_address import SCAddress -from .sc_val import SCVal +from .int64 import Int64 from .uint32 import Uint32 - -__all__ = ["SorobanAddressCredentials"] - - +from .sc_val import SCVal +__all__ = ['SorobanAddressCredentials'] class SorobanAddressCredentials: """ XDR Source Code:: @@ -22,11 +22,10 @@ class SorobanAddressCredentials: { SCAddress address; int64 nonce; - uint32 signatureExpirationLedger; + uint32 signatureExpirationLedger; SCVal signature; }; """ - def __init__( self, address: SCAddress, @@ -38,13 +37,11 @@ def __init__( self.nonce = nonce self.signature_expiration_ledger = signature_expiration_ledger self.signature = signature - def pack(self, packer: Packer) -> None: self.address.pack(packer) self.nonce.pack(packer) self.signature_expiration_ledger.pack(packer) self.signature.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SorobanAddressCredentials: address = SCAddress.unpack(unpacker) @@ -57,7 +54,6 @@ def unpack(cls, unpacker: Unpacker) -> SorobanAddressCredentials: signature_expiration_ledger=signature_expiration_ledger, signature=signature, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -76,32 +72,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SorobanAddressCredentials: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.address, - self.nonce, - self.signature_expiration_ledger, - self.signature, - ) - ) - + return hash((self.address, self.nonce, self.signature_expiration_ledger, self.signature,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.address == other.address - and self.nonce == other.nonce - and self.signature_expiration_ledger == other.signature_expiration_ledger - and self.signature == other.signature - ) - + return self.address== other.address and self.nonce== other.nonce and self.signature_expiration_ledger== other.signature_expiration_ledger and self.signature== other.signature def __str__(self): out = [ - f"address={self.address}", - f"nonce={self.nonce}", - f"signature_expiration_ledger={self.signature_expiration_ledger}", - f"signature={self.signature}", + f'address={self.address}', + f'nonce={self.nonce}', + f'signature_expiration_ledger={self.signature_expiration_ledger}', + f'signature={self.signature}', ] return f"" diff --git a/stellar_sdk/xdr/soroban_authorization_entry.py b/stellar_sdk/xdr/soroban_authorization_entry.py index 7ea04b55..ff5d6caa 100644 --- a/stellar_sdk/xdr/soroban_authorization_entry.py +++ b/stellar_sdk/xdr/soroban_authorization_entry.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .soroban_authorized_invocation import SorobanAuthorizedInvocation from .soroban_credentials import SorobanCredentials - -__all__ = ["SorobanAuthorizationEntry"] - - +from .soroban_authorized_invocation import SorobanAuthorizedInvocation +__all__ = ['SorobanAuthorizationEntry'] class SorobanAuthorizationEntry: """ XDR Source Code:: @@ -22,7 +22,6 @@ class SorobanAuthorizationEntry: SorobanAuthorizedInvocation rootInvocation; }; """ - def __init__( self, credentials: SorobanCredentials, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.credentials = credentials self.root_invocation = root_invocation - def pack(self, packer: Packer) -> None: self.credentials.pack(packer) self.root_invocation.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SorobanAuthorizationEntry: credentials = SorobanCredentials.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> SorobanAuthorizationEntry: credentials=credentials, root_invocation=root_invocation, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SorobanAuthorizationEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.credentials, - self.root_invocation, - ) - ) - + return hash((self.credentials, self.root_invocation,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.credentials == other.credentials - and self.root_invocation == other.root_invocation - ) - + return self.credentials== other.credentials and self.root_invocation== other.root_invocation def __str__(self): out = [ - f"credentials={self.credentials}", - f"root_invocation={self.root_invocation}", + f'credentials={self.credentials}', + f'root_invocation={self.root_invocation}', ] return f"" diff --git a/stellar_sdk/xdr/soroban_authorized_function.py b/stellar_sdk/xdr/soroban_authorized_function.py index 1cdbab2f..33c7b4f3 100644 --- a/stellar_sdk/xdr/soroban_authorized_function.py +++ b/stellar_sdk/xdr/soroban_authorized_function.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .create_contract_args import CreateContractArgs -from .invoke_contract_args import InvokeContractArgs from .soroban_authorized_function_type import SorobanAuthorizedFunctionType - -__all__ = ["SorobanAuthorizedFunction"] - - +from .invoke_contract_args import InvokeContractArgs +from .create_contract_args import CreateContractArgs +__all__ = ['SorobanAuthorizedFunction'] class SorobanAuthorizedFunction: """ XDR Source Code:: @@ -25,7 +25,6 @@ class SorobanAuthorizedFunction: CreateContractArgs createContractHostFn; }; """ - def __init__( self, type: SorobanAuthorizedFunctionType, @@ -35,43 +34,28 @@ def __init__( self.type = type self.contract_fn = contract_fn self.create_contract_host_fn = create_contract_host_fn - def pack(self, packer: Packer) -> None: self.type.pack(packer) - if ( - self.type - == SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN - ): + if self.type == SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: if self.contract_fn is None: raise ValueError("contract_fn should not be None.") self.contract_fn.pack(packer) return - if ( - self.type - == SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN - ): + if self.type == SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: if self.create_contract_host_fn is None: raise ValueError("create_contract_host_fn should not be None.") self.create_contract_host_fn.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SorobanAuthorizedFunction: type = SorobanAuthorizedFunctionType.unpack(unpacker) - if ( - type - == SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN - ): + if type == SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: contract_fn = InvokeContractArgs.unpack(unpacker) return cls(type=type, contract_fn=contract_fn) - if ( - type - == SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN - ): + if type == SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: create_contract_host_fn = CreateContractArgs.unpack(unpacker) return cls(type=type, create_contract_host_fn=create_contract_host_fn) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -90,32 +74,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SorobanAuthorizedFunction: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.contract_fn, - self.create_contract_host_fn, - ) - ) - + return hash((self.type, self.contract_fn, self.create_contract_host_fn,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.contract_fn == other.contract_fn - and self.create_contract_host_fn == other.create_contract_host_fn - ) - + return self.type== other.type and self.contract_fn== other.contract_fn and self.create_contract_host_fn== other.create_contract_host_fn def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"contract_fn={self.contract_fn}" - ) if self.contract_fn is not None else None - out.append( - f"create_contract_host_fn={self.create_contract_host_fn}" - ) if self.create_contract_host_fn is not None else None + out.append(f'type={self.type}') + out.append(f'contract_fn={self.contract_fn}') if self.contract_fn is not None else None + out.append(f'create_contract_host_fn={self.create_contract_host_fn}') if self.create_contract_host_fn is not None else None return f"" diff --git a/stellar_sdk/xdr/soroban_authorized_function_type.py b/stellar_sdk/xdr/soroban_authorized_function_type.py index b52f1139..fa8fe93a 100644 --- a/stellar_sdk/xdr/soroban_authorized_function_type.py +++ b/stellar_sdk/xdr/soroban_authorized_function_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SorobanAuthorizedFunctionType"] - - +__all__ = ['SorobanAuthorizedFunctionType'] class SorobanAuthorizedFunctionType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class SorobanAuthorizedFunctionType(IntEnum): SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 }; """ - SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0 SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SorobanAuthorizedFunctionType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/soroban_authorized_invocation.py b/stellar_sdk/xdr/soroban_authorized_invocation.py index 9b90d64e..734c7863 100644 --- a/stellar_sdk/xdr/soroban_authorized_invocation.py +++ b/stellar_sdk/xdr/soroban_authorized_invocation.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .soroban_authorized_function import SorobanAuthorizedFunction - -__all__ = ["SorobanAuthorizedInvocation"] - - +__all__ = ['SorobanAuthorizedInvocation'] class SorobanAuthorizedInvocation: """ XDR Source Code:: @@ -22,7 +21,6 @@ class SorobanAuthorizedInvocation: SorobanAuthorizedInvocation subInvocations<>; }; """ - def __init__( self, function: SorobanAuthorizedFunction, @@ -30,18 +28,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if sub_invocations and len(sub_invocations) > _expect_max_length: - raise ValueError( - f"The maximum length of `sub_invocations` should be {_expect_max_length}, but got {len(sub_invocations)}." - ) + raise ValueError(f"The maximum length of `sub_invocations` should be {_expect_max_length}, but got {len(sub_invocations)}.") self.function = function self.sub_invocations = sub_invocations - def pack(self, packer: Packer) -> None: self.function.pack(packer) packer.pack_uint(len(self.sub_invocations)) for sub_invocations_item in self.sub_invocations: sub_invocations_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SorobanAuthorizedInvocation: function = SorobanAuthorizedFunction.unpack(unpacker) @@ -53,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> SorobanAuthorizedInvocation: function=function, sub_invocations=sub_invocations, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -72,26 +65,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SorobanAuthorizedInvocation: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.function, - self.sub_invocations, - ) - ) - + return hash((self.function, self.sub_invocations,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.function == other.function - and self.sub_invocations == other.sub_invocations - ) - + return self.function== other.function and self.sub_invocations== other.sub_invocations def __str__(self): out = [ - f"function={self.function}", - f"sub_invocations={self.sub_invocations}", + f'function={self.function}', + f'sub_invocations={self.sub_invocations}', ] return f"" diff --git a/stellar_sdk/xdr/soroban_credentials.py b/stellar_sdk/xdr/soroban_credentials.py index 93822b36..c7ca9f4d 100644 --- a/stellar_sdk/xdr/soroban_credentials.py +++ b/stellar_sdk/xdr/soroban_credentials.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .soroban_address_credentials import SorobanAddressCredentials from .soroban_credentials_type import SorobanCredentialsType - -__all__ = ["SorobanCredentials"] - - +from .soroban_address_credentials import SorobanAddressCredentials +__all__ = ['SorobanCredentials'] class SorobanCredentials: """ XDR Source Code:: @@ -24,7 +24,6 @@ class SorobanCredentials: SorobanAddressCredentials address; }; """ - def __init__( self, type: SorobanCredentialsType, @@ -32,7 +31,6 @@ def __init__( ) -> None: self.type = type self.address = address - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == SorobanCredentialsType.SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: @@ -42,7 +40,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("address should not be None.") self.address.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SorobanCredentials: type = SorobanCredentialsType.unpack(unpacker) @@ -52,7 +49,6 @@ def unpack(cls, unpacker: Unpacker) -> SorobanCredentials: address = SorobanAddressCredentials.unpack(unpacker) return cls(type=type, address=address) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,22 +67,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SorobanCredentials: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.address, - ) - ) - + return hash((self.type, self.address,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.type == other.type and self.address == other.address - + return self.type== other.type and self.address== other.address def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"address={self.address}") if self.address is not None else None + out.append(f'type={self.type}') + out.append(f'address={self.address}') if self.address is not None else None return f"" diff --git a/stellar_sdk/xdr/soroban_credentials_type.py b/stellar_sdk/xdr/soroban_credentials_type.py index b07bf1a0..a3fa571a 100644 --- a/stellar_sdk/xdr/soroban_credentials_type.py +++ b/stellar_sdk/xdr/soroban_credentials_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SorobanCredentialsType"] - - +__all__ = ['SorobanCredentialsType'] class SorobanCredentialsType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class SorobanCredentialsType(IntEnum): SOROBAN_CREDENTIALS_ADDRESS = 1 }; """ - SOROBAN_CREDENTIALS_SOURCE_ACCOUNT = 0 SOROBAN_CREDENTIALS_ADDRESS = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SorobanCredentialsType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/soroban_resources.py b/stellar_sdk/xdr/soroban_resources.py index d74f4440..83048718 100644 --- a/stellar_sdk/xdr/soroban_resources.py +++ b/stellar_sdk/xdr/soroban_resources.py @@ -3,25 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .ledger_footprint import LedgerFootprint from .uint32 import Uint32 - -__all__ = ["SorobanResources"] - - +from .uint32 import Uint32 +from .uint32 import Uint32 +__all__ = ['SorobanResources'] class SorobanResources: """ XDR Source Code:: struct SorobanResources - { + { // The ledger footprint of the transaction. LedgerFootprint footprint; // The maximum number of instructions this transaction can use - uint32 instructions; + uint32 instructions; // The maximum number of bytes this transaction can read from ledger uint32 readBytes; @@ -29,7 +31,6 @@ class SorobanResources: uint32 writeBytes; }; """ - def __init__( self, footprint: LedgerFootprint, @@ -41,13 +42,11 @@ def __init__( self.instructions = instructions self.read_bytes = read_bytes self.write_bytes = write_bytes - def pack(self, packer: Packer) -> None: self.footprint.pack(packer) self.instructions.pack(packer) self.read_bytes.pack(packer) self.write_bytes.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SorobanResources: footprint = LedgerFootprint.unpack(unpacker) @@ -60,7 +59,6 @@ def unpack(cls, unpacker: Unpacker) -> SorobanResources: read_bytes=read_bytes, write_bytes=write_bytes, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -79,32 +77,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SorobanResources: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.footprint, - self.instructions, - self.read_bytes, - self.write_bytes, - ) - ) - + return hash((self.footprint, self.instructions, self.read_bytes, self.write_bytes,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.footprint == other.footprint - and self.instructions == other.instructions - and self.read_bytes == other.read_bytes - and self.write_bytes == other.write_bytes - ) - + return self.footprint== other.footprint and self.instructions== other.instructions and self.read_bytes== other.read_bytes and self.write_bytes== other.write_bytes def __str__(self): out = [ - f"footprint={self.footprint}", - f"instructions={self.instructions}", - f"read_bytes={self.read_bytes}", - f"write_bytes={self.write_bytes}", + f'footprint={self.footprint}', + f'instructions={self.instructions}', + f'read_bytes={self.read_bytes}', + f'write_bytes={self.write_bytes}', ] return f"" diff --git a/stellar_sdk/xdr/soroban_transaction_data.py b/stellar_sdk/xdr/soroban_transaction_data.py index 2fd42875..ece72a9a 100644 --- a/stellar_sdk/xdr/soroban_transaction_data.py +++ b/stellar_sdk/xdr/soroban_transaction_data.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .extension_point import ExtensionPoint -from .int64 import Int64 from .soroban_resources import SorobanResources - -__all__ = ["SorobanTransactionData"] - - +from .int64 import Int64 +__all__ = ['SorobanTransactionData'] class SorobanTransactionData: """ XDR Source Code:: @@ -25,7 +25,6 @@ class SorobanTransactionData: int64 refundableFee; }; """ - def __init__( self, ext: ExtensionPoint, @@ -35,12 +34,10 @@ def __init__( self.ext = ext self.resources = resources self.refundable_fee = refundable_fee - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.resources.pack(packer) self.refundable_fee.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SorobanTransactionData: ext = ExtensionPoint.unpack(unpacker) @@ -51,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> SorobanTransactionData: resources=resources, refundable_fee=refundable_fee, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -70,29 +66,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SorobanTransactionData: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.resources, - self.refundable_fee, - ) - ) - + return hash((self.ext, self.resources, self.refundable_fee,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.resources == other.resources - and self.refundable_fee == other.refundable_fee - ) - + return self.ext== other.ext and self.resources== other.resources and self.refundable_fee== other.refundable_fee def __str__(self): out = [ - f"ext={self.ext}", - f"resources={self.resources}", - f"refundable_fee={self.refundable_fee}", + f'ext={self.ext}', + f'resources={self.resources}', + f'refundable_fee={self.refundable_fee}', ] return f"" diff --git a/stellar_sdk/xdr/soroban_transaction_meta.py b/stellar_sdk/xdr/soroban_transaction_meta.py index 307a06f9..1d674a07 100644 --- a/stellar_sdk/xdr/soroban_transaction_meta.py +++ b/stellar_sdk/xdr/soroban_transaction_meta.py @@ -3,23 +3,22 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .contract_event import ContractEvent -from .diagnostic_event import DiagnosticEvent from .extension_point import ExtensionPoint +from .contract_event import ContractEvent from .sc_val import SCVal - -__all__ = ["SorobanTransactionMeta"] - - +from .diagnostic_event import DiagnosticEvent +__all__ = ['SorobanTransactionMeta'] class SorobanTransactionMeta: """ XDR Source Code:: - struct SorobanTransactionMeta + struct SorobanTransactionMeta { ExtensionPoint ext; @@ -33,7 +32,6 @@ class SorobanTransactionMeta: DiagnosticEvent diagnosticEvents<>; }; """ - def __init__( self, ext: ExtensionPoint, @@ -43,19 +41,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if events and len(events) > _expect_max_length: - raise ValueError( - f"The maximum length of `events` should be {_expect_max_length}, but got {len(events)}." - ) + raise ValueError(f"The maximum length of `events` should be {_expect_max_length}, but got {len(events)}.") _expect_max_length = 4294967295 if diagnostic_events and len(diagnostic_events) > _expect_max_length: - raise ValueError( - f"The maximum length of `diagnostic_events` should be {_expect_max_length}, but got {len(diagnostic_events)}." - ) + raise ValueError(f"The maximum length of `diagnostic_events` should be {_expect_max_length}, but got {len(diagnostic_events)}.") self.ext = ext self.events = events self.return_value = return_value self.diagnostic_events = diagnostic_events - def pack(self, packer: Packer) -> None: self.ext.pack(packer) packer.pack_uint(len(self.events)) @@ -65,7 +58,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.diagnostic_events)) for diagnostic_events_item in self.diagnostic_events: diagnostic_events_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SorobanTransactionMeta: ext = ExtensionPoint.unpack(unpacker) @@ -84,7 +76,6 @@ def unpack(cls, unpacker: Unpacker) -> SorobanTransactionMeta: return_value=return_value, diagnostic_events=diagnostic_events, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -103,32 +94,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SorobanTransactionMeta: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.events, - self.return_value, - self.diagnostic_events, - ) - ) - + return hash((self.ext, self.events, self.return_value, self.diagnostic_events,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.events == other.events - and self.return_value == other.return_value - and self.diagnostic_events == other.diagnostic_events - ) - + return self.ext== other.ext and self.events== other.events and self.return_value== other.return_value and self.diagnostic_events== other.diagnostic_events def __str__(self): out = [ - f"ext={self.ext}", - f"events={self.events}", - f"return_value={self.return_value}", - f"diagnostic_events={self.diagnostic_events}", + f'ext={self.ext}', + f'events={self.events}', + f'return_value={self.return_value}', + f'diagnostic_events={self.diagnostic_events}', ] return f"" diff --git a/stellar_sdk/xdr/sponsorship_descriptor.py b/stellar_sdk/xdr/sponsorship_descriptor.py index cd95c088..772a9017 100644 --- a/stellar_sdk/xdr/sponsorship_descriptor.py +++ b/stellar_sdk/xdr/sponsorship_descriptor.py @@ -3,39 +3,32 @@ from __future__ import annotations import base64 -from typing import Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID - -__all__ = ["SponsorshipDescriptor"] - - +__all__ = ['SponsorshipDescriptor'] class SponsorshipDescriptor: """ XDR Source Code:: typedef AccountID* SponsorshipDescriptor; """ - def __init__(self, sponsorship_descriptor: Optional[AccountID]) -> None: self.sponsorship_descriptor = sponsorship_descriptor - def pack(self, packer: Packer) -> None: if self.sponsorship_descriptor is None: packer.pack_uint(0) else: packer.pack_uint(1) self.sponsorship_descriptor.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SponsorshipDescriptor: - sponsorship_descriptor = ( - AccountID.unpack(unpacker) if unpacker.unpack_uint() else None - ) + sponsorship_descriptor = AccountID.unpack(unpacker) if unpacker.unpack_uint() else None return cls(sponsorship_descriptor) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -54,10 +47,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SponsorshipDescriptor: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.sponsorship_descriptor) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/state_expiration_settings.py b/stellar_sdk/xdr/state_expiration_settings.py index 0b4f6729..27cd8b76 100644 --- a/stellar_sdk/xdr/state_expiration_settings.py +++ b/stellar_sdk/xdr/state_expiration_settings.py @@ -3,16 +3,22 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +from .int64 import Int64 from .int64 import Int64 from .uint32 import Uint32 +from .uint32 import Uint32 from .uint64 import Uint64 - -__all__ = ["StateExpirationSettings"] - - +from .uint32 import Uint32 +__all__ = ['StateExpirationSettings'] class StateExpirationSettings: """ XDR Source Code:: @@ -39,7 +45,6 @@ class StateExpirationSettings: uint32 startingEvictionScanLevel; }; """ - def __init__( self, max_entry_expiration: Uint32, @@ -61,7 +66,6 @@ def __init__( self.bucket_list_size_window_sample_size = bucket_list_size_window_sample_size self.eviction_scan_size = eviction_scan_size self.starting_eviction_scan_level = starting_eviction_scan_level - def pack(self, packer: Packer) -> None: self.max_entry_expiration.pack(packer) self.min_temp_entry_expiration.pack(packer) @@ -72,7 +76,6 @@ def pack(self, packer: Packer) -> None: self.bucket_list_size_window_sample_size.pack(packer) self.eviction_scan_size.pack(packer) self.starting_eviction_scan_level.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> StateExpirationSettings: max_entry_expiration = Uint32.unpack(unpacker) @@ -95,7 +98,6 @@ def unpack(cls, unpacker: Unpacker) -> StateExpirationSettings: eviction_scan_size=eviction_scan_size, starting_eviction_scan_level=starting_eviction_scan_level, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -114,50 +116,22 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> StateExpirationSettings: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.max_entry_expiration, - self.min_temp_entry_expiration, - self.min_persistent_entry_expiration, - self.persistent_rent_rate_denominator, - self.temp_rent_rate_denominator, - self.max_entries_to_expire, - self.bucket_list_size_window_sample_size, - self.eviction_scan_size, - self.starting_eviction_scan_level, - ) - ) - + return hash((self.max_entry_expiration, self.min_temp_entry_expiration, self.min_persistent_entry_expiration, self.persistent_rent_rate_denominator, self.temp_rent_rate_denominator, self.max_entries_to_expire, self.bucket_list_size_window_sample_size, self.eviction_scan_size, self.starting_eviction_scan_level,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.max_entry_expiration == other.max_entry_expiration - and self.min_temp_entry_expiration == other.min_temp_entry_expiration - and self.min_persistent_entry_expiration - == other.min_persistent_entry_expiration - and self.persistent_rent_rate_denominator - == other.persistent_rent_rate_denominator - and self.temp_rent_rate_denominator == other.temp_rent_rate_denominator - and self.max_entries_to_expire == other.max_entries_to_expire - and self.bucket_list_size_window_sample_size - == other.bucket_list_size_window_sample_size - and self.eviction_scan_size == other.eviction_scan_size - and self.starting_eviction_scan_level == other.starting_eviction_scan_level - ) - + return self.max_entry_expiration== other.max_entry_expiration and self.min_temp_entry_expiration== other.min_temp_entry_expiration and self.min_persistent_entry_expiration== other.min_persistent_entry_expiration and self.persistent_rent_rate_denominator== other.persistent_rent_rate_denominator and self.temp_rent_rate_denominator== other.temp_rent_rate_denominator and self.max_entries_to_expire== other.max_entries_to_expire and self.bucket_list_size_window_sample_size== other.bucket_list_size_window_sample_size and self.eviction_scan_size== other.eviction_scan_size and self.starting_eviction_scan_level== other.starting_eviction_scan_level def __str__(self): out = [ - f"max_entry_expiration={self.max_entry_expiration}", - f"min_temp_entry_expiration={self.min_temp_entry_expiration}", - f"min_persistent_entry_expiration={self.min_persistent_entry_expiration}", - f"persistent_rent_rate_denominator={self.persistent_rent_rate_denominator}", - f"temp_rent_rate_denominator={self.temp_rent_rate_denominator}", - f"max_entries_to_expire={self.max_entries_to_expire}", - f"bucket_list_size_window_sample_size={self.bucket_list_size_window_sample_size}", - f"eviction_scan_size={self.eviction_scan_size}", - f"starting_eviction_scan_level={self.starting_eviction_scan_level}", + f'max_entry_expiration={self.max_entry_expiration}', + f'min_temp_entry_expiration={self.min_temp_entry_expiration}', + f'min_persistent_entry_expiration={self.min_persistent_entry_expiration}', + f'persistent_rent_rate_denominator={self.persistent_rent_rate_denominator}', + f'temp_rent_rate_denominator={self.temp_rent_rate_denominator}', + f'max_entries_to_expire={self.max_entries_to_expire}', + f'bucket_list_size_window_sample_size={self.bucket_list_size_window_sample_size}', + f'eviction_scan_size={self.eviction_scan_size}', + f'starting_eviction_scan_level={self.starting_eviction_scan_level}', ] return f"" diff --git a/stellar_sdk/xdr/stellar_message.py b/stellar_sdk/xdr/stellar_message.py index c7c9e0a0..874d264a 100644 --- a/stellar_sdk/xdr/stellar_message.py +++ b/stellar_sdk/xdr/stellar_message.py @@ -3,33 +3,33 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .auth import Auth -from .dont_have import DontHave +from .message_type import MessageType from .error import Error -from .flood_advert import FloodAdvert -from .flood_demand import FloodDemand -from .generalized_transaction_set import GeneralizedTransactionSet from .hello import Hello -from .message_type import MessageType +from .auth import Auth +from .dont_have import DontHave from .peer_address import PeerAddress -from .scp_envelope import SCPEnvelope -from .scp_quorum_set import SCPQuorumSet -from .send_more import SendMore -from .send_more_extended import SendMoreExtended +from .uint256 import Uint256 +from .transaction_set import TransactionSet +from .generalized_transaction_set import GeneralizedTransactionSet +from .transaction_envelope import TransactionEnvelope from .signed_survey_request_message import SignedSurveyRequestMessage from .signed_survey_response_message import SignedSurveyResponseMessage -from .transaction_envelope import TransactionEnvelope -from .transaction_set import TransactionSet -from .uint32 import Uint32 from .uint256 import Uint256 - -__all__ = ["StellarMessage"] - - +from .scp_quorum_set import SCPQuorumSet +from .scp_envelope import SCPEnvelope +from .uint32 import Uint32 +from .send_more import SendMore +from .send_more_extended import SendMoreExtended +from .flood_advert import FloodAdvert +from .flood_demand import FloodDemand +__all__ = ['StellarMessage'] class StellarMessage: """ XDR Source Code:: @@ -85,7 +85,6 @@ class StellarMessage: FloodDemand floodDemand; }; """ - def __init__( self, type: MessageType, @@ -111,9 +110,7 @@ def __init__( ) -> None: _expect_max_length = 100 if peers and len(peers) > _expect_max_length: - raise ValueError( - f"The maximum length of `peers` should be {_expect_max_length}, but got {len(peers)}." - ) + raise ValueError(f"The maximum length of `peers` should be {_expect_max_length}, but got {len(peers)}.") self.type = type self.error = error self.hello = hello @@ -134,7 +131,6 @@ def __init__( self.send_more_extended_message = send_more_extended_message self.flood_advert = flood_advert self.flood_demand = flood_demand - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == MessageType.ERROR_MSG: @@ -236,7 +232,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("flood_demand should not be None.") self.flood_demand.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> StellarMessage: type = MessageType.unpack(unpacker) @@ -274,16 +269,10 @@ def unpack(cls, unpacker: Unpacker) -> StellarMessage: return cls(type=type, transaction=transaction) if type == MessageType.SURVEY_REQUEST: signed_survey_request_message = SignedSurveyRequestMessage.unpack(unpacker) - return cls( - type=type, signed_survey_request_message=signed_survey_request_message - ) + return cls(type=type, signed_survey_request_message=signed_survey_request_message) if type == MessageType.SURVEY_RESPONSE: - signed_survey_response_message = SignedSurveyResponseMessage.unpack( - unpacker - ) - return cls( - type=type, signed_survey_response_message=signed_survey_response_message - ) + signed_survey_response_message = SignedSurveyResponseMessage.unpack(unpacker) + return cls(type=type, signed_survey_response_message=signed_survey_response_message) if type == MessageType.GET_SCP_QUORUMSET: q_set_hash = Uint256.unpack(unpacker) return cls(type=type, q_set_hash=q_set_hash) @@ -309,7 +298,6 @@ def unpack(cls, unpacker: Unpacker) -> StellarMessage: flood_demand = FloodDemand.unpack(unpacker) return cls(type=type, flood_demand=flood_demand) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -328,105 +316,32 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> StellarMessage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.error, - self.hello, - self.auth, - self.dont_have, - self.peers, - self.tx_set_hash, - self.tx_set, - self.generalized_tx_set, - self.transaction, - self.signed_survey_request_message, - self.signed_survey_response_message, - self.q_set_hash, - self.q_set, - self.envelope, - self.get_scp_ledger_seq, - self.send_more_message, - self.send_more_extended_message, - self.flood_advert, - self.flood_demand, - ) - ) - + return hash((self.type, self.error, self.hello, self.auth, self.dont_have, self.peers, self.tx_set_hash, self.tx_set, self.generalized_tx_set, self.transaction, self.signed_survey_request_message, self.signed_survey_response_message, self.q_set_hash, self.q_set, self.envelope, self.get_scp_ledger_seq, self.send_more_message, self.send_more_extended_message, self.flood_advert, self.flood_demand,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.error == other.error - and self.hello == other.hello - and self.auth == other.auth - and self.dont_have == other.dont_have - and self.peers == other.peers - and self.tx_set_hash == other.tx_set_hash - and self.tx_set == other.tx_set - and self.generalized_tx_set == other.generalized_tx_set - and self.transaction == other.transaction - and self.signed_survey_request_message - == other.signed_survey_request_message - and self.signed_survey_response_message - == other.signed_survey_response_message - and self.q_set_hash == other.q_set_hash - and self.q_set == other.q_set - and self.envelope == other.envelope - and self.get_scp_ledger_seq == other.get_scp_ledger_seq - and self.send_more_message == other.send_more_message - and self.send_more_extended_message == other.send_more_extended_message - and self.flood_advert == other.flood_advert - and self.flood_demand == other.flood_demand - ) - + return self.type== other.type and self.error== other.error and self.hello== other.hello and self.auth== other.auth and self.dont_have== other.dont_have and self.peers== other.peers and self.tx_set_hash== other.tx_set_hash and self.tx_set== other.tx_set and self.generalized_tx_set== other.generalized_tx_set and self.transaction== other.transaction and self.signed_survey_request_message== other.signed_survey_request_message and self.signed_survey_response_message== other.signed_survey_response_message and self.q_set_hash== other.q_set_hash and self.q_set== other.q_set and self.envelope== other.envelope and self.get_scp_ledger_seq== other.get_scp_ledger_seq and self.send_more_message== other.send_more_message and self.send_more_extended_message== other.send_more_extended_message and self.flood_advert== other.flood_advert and self.flood_demand== other.flood_demand def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"error={self.error}") if self.error is not None else None - out.append(f"hello={self.hello}") if self.hello is not None else None - out.append(f"auth={self.auth}") if self.auth is not None else None - out.append( - f"dont_have={self.dont_have}" - ) if self.dont_have is not None else None - out.append(f"peers={self.peers}") if self.peers is not None else None - out.append( - f"tx_set_hash={self.tx_set_hash}" - ) if self.tx_set_hash is not None else None - out.append(f"tx_set={self.tx_set}") if self.tx_set is not None else None - out.append( - f"generalized_tx_set={self.generalized_tx_set}" - ) if self.generalized_tx_set is not None else None - out.append( - f"transaction={self.transaction}" - ) if self.transaction is not None else None - out.append( - f"signed_survey_request_message={self.signed_survey_request_message}" - ) if self.signed_survey_request_message is not None else None - out.append( - f"signed_survey_response_message={self.signed_survey_response_message}" - ) if self.signed_survey_response_message is not None else None - out.append( - f"q_set_hash={self.q_set_hash}" - ) if self.q_set_hash is not None else None - out.append(f"q_set={self.q_set}") if self.q_set is not None else None - out.append(f"envelope={self.envelope}") if self.envelope is not None else None - out.append( - f"get_scp_ledger_seq={self.get_scp_ledger_seq}" - ) if self.get_scp_ledger_seq is not None else None - out.append( - f"send_more_message={self.send_more_message}" - ) if self.send_more_message is not None else None - out.append( - f"send_more_extended_message={self.send_more_extended_message}" - ) if self.send_more_extended_message is not None else None - out.append( - f"flood_advert={self.flood_advert}" - ) if self.flood_advert is not None else None - out.append( - f"flood_demand={self.flood_demand}" - ) if self.flood_demand is not None else None + out.append(f'type={self.type}') + out.append(f'error={self.error}') if self.error is not None else None + out.append(f'hello={self.hello}') if self.hello is not None else None + out.append(f'auth={self.auth}') if self.auth is not None else None + out.append(f'dont_have={self.dont_have}') if self.dont_have is not None else None + out.append(f'peers={self.peers}') if self.peers is not None else None + out.append(f'tx_set_hash={self.tx_set_hash}') if self.tx_set_hash is not None else None + out.append(f'tx_set={self.tx_set}') if self.tx_set is not None else None + out.append(f'generalized_tx_set={self.generalized_tx_set}') if self.generalized_tx_set is not None else None + out.append(f'transaction={self.transaction}') if self.transaction is not None else None + out.append(f'signed_survey_request_message={self.signed_survey_request_message}') if self.signed_survey_request_message is not None else None + out.append(f'signed_survey_response_message={self.signed_survey_response_message}') if self.signed_survey_response_message is not None else None + out.append(f'q_set_hash={self.q_set_hash}') if self.q_set_hash is not None else None + out.append(f'q_set={self.q_set}') if self.q_set is not None else None + out.append(f'envelope={self.envelope}') if self.envelope is not None else None + out.append(f'get_scp_ledger_seq={self.get_scp_ledger_seq}') if self.get_scp_ledger_seq is not None else None + out.append(f'send_more_message={self.send_more_message}') if self.send_more_message is not None else None + out.append(f'send_more_extended_message={self.send_more_extended_message}') if self.send_more_extended_message is not None else None + out.append(f'flood_advert={self.flood_advert}') if self.flood_advert is not None else None + out.append(f'flood_demand={self.flood_demand}') if self.flood_demand is not None else None return f"" diff --git a/stellar_sdk/xdr/stellar_value.py b/stellar_sdk/xdr/stellar_value.py index 3f7b80ab..0f5b6c23 100644 --- a/stellar_sdk/xdr/stellar_value.py +++ b/stellar_sdk/xdr/stellar_value.py @@ -3,18 +3,17 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash -from .stellar_value_ext import StellarValueExt from .time_point import TimePoint from .upgrade_type import UpgradeType - -__all__ = ["StellarValue"] - - +from .stellar_value_ext import StellarValueExt +__all__ = ['StellarValue'] class StellarValue: """ XDR Source Code:: @@ -42,7 +41,6 @@ class StellarValue: ext; }; """ - def __init__( self, tx_set_hash: Hash, @@ -52,14 +50,11 @@ def __init__( ) -> None: _expect_max_length = 6 if upgrades and len(upgrades) > _expect_max_length: - raise ValueError( - f"The maximum length of `upgrades` should be {_expect_max_length}, but got {len(upgrades)}." - ) + raise ValueError(f"The maximum length of `upgrades` should be {_expect_max_length}, but got {len(upgrades)}.") self.tx_set_hash = tx_set_hash self.close_time = close_time self.upgrades = upgrades self.ext = ext - def pack(self, packer: Packer) -> None: self.tx_set_hash.pack(packer) self.close_time.pack(packer) @@ -67,7 +62,6 @@ def pack(self, packer: Packer) -> None: for upgrades_item in self.upgrades: upgrades_item.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> StellarValue: tx_set_hash = Hash.unpack(unpacker) @@ -83,7 +77,6 @@ def unpack(cls, unpacker: Unpacker) -> StellarValue: upgrades=upgrades, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,32 +95,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> StellarValue: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.tx_set_hash, - self.close_time, - self.upgrades, - self.ext, - ) - ) - + return hash((self.tx_set_hash, self.close_time, self.upgrades, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.tx_set_hash == other.tx_set_hash - and self.close_time == other.close_time - and self.upgrades == other.upgrades - and self.ext == other.ext - ) - + return self.tx_set_hash== other.tx_set_hash and self.close_time== other.close_time and self.upgrades== other.upgrades and self.ext== other.ext def __str__(self): out = [ - f"tx_set_hash={self.tx_set_hash}", - f"close_time={self.close_time}", - f"upgrades={self.upgrades}", - f"ext={self.ext}", + f'tx_set_hash={self.tx_set_hash}', + f'close_time={self.close_time}', + f'upgrades={self.upgrades}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/stellar_value_ext.py b/stellar_sdk/xdr/stellar_value_ext.py index 9a6159d4..26483f25 100644 --- a/stellar_sdk/xdr/stellar_value_ext.py +++ b/stellar_sdk/xdr/stellar_value_ext.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .ledger_close_value_signature import LedgerCloseValueSignature from .stellar_value_type import StellarValueType - -__all__ = ["StellarValueExt"] - - +from .ledger_close_value_signature import LedgerCloseValueSignature +__all__ = ['StellarValueExt'] class StellarValueExt: """ XDR Source Code:: @@ -24,7 +24,6 @@ class StellarValueExt: LedgerCloseValueSignature lcValueSignature; } """ - def __init__( self, v: StellarValueType, @@ -32,7 +31,6 @@ def __init__( ) -> None: self.v = v self.lc_value_signature = lc_value_signature - def pack(self, packer: Packer) -> None: self.v.pack(packer) if self.v == StellarValueType.STELLAR_VALUE_BASIC: @@ -42,7 +40,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("lc_value_signature should not be None.") self.lc_value_signature.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> StellarValueExt: v = StellarValueType.unpack(unpacker) @@ -52,7 +49,6 @@ def unpack(cls, unpacker: Unpacker) -> StellarValueExt: lc_value_signature = LedgerCloseValueSignature.unpack(unpacker) return cls(v=v, lc_value_signature=lc_value_signature) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,24 +67,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> StellarValueExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.lc_value_signature, - ) - ) - + return hash((self.v, self.lc_value_signature,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.lc_value_signature == other.lc_value_signature - + return self.v== other.v and self.lc_value_signature== other.lc_value_signature def __str__(self): out = [] - out.append(f"v={self.v}") - out.append( - f"lc_value_signature={self.lc_value_signature}" - ) if self.lc_value_signature is not None else None + out.append(f'v={self.v}') + out.append(f'lc_value_signature={self.lc_value_signature}') if self.lc_value_signature is not None else None return f"" diff --git a/stellar_sdk/xdr/stellar_value_type.py b/stellar_sdk/xdr/stellar_value_type.py index 0004b7fe..3eb2088b 100644 --- a/stellar_sdk/xdr/stellar_value_type.py +++ b/stellar_sdk/xdr/stellar_value_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["StellarValueType"] - - +__all__ = ['StellarValueType'] class StellarValueType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class StellarValueType(IntEnum): STELLAR_VALUE_SIGNED = 1 }; """ - STELLAR_VALUE_BASIC = 0 STELLAR_VALUE_SIGNED = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> StellarValueType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/stored_transaction_set.py b/stellar_sdk/xdr/stored_transaction_set.py index 68000726..91836328 100644 --- a/stellar_sdk/xdr/stored_transaction_set.py +++ b/stellar_sdk/xdr/stored_transaction_set.py @@ -3,29 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer -from .generalized_transaction_set import GeneralizedTransactionSet from .transaction_set import TransactionSet - -__all__ = ["StoredTransactionSet"] - - +from .generalized_transaction_set import GeneralizedTransactionSet +__all__ = ['StoredTransactionSet'] class StoredTransactionSet: """ XDR Source Code:: - union StoredTransactionSet switch (int v) - { - case 0: - TransactionSet txSet; - case 1: - GeneralizedTransactionSet generalizedTxSet; - }; + union StoredTransactionSet switch (int v) + { + case 0: + TransactionSet txSet; + case 1: + GeneralizedTransactionSet generalizedTxSet; + }; """ - def __init__( self, v: int, @@ -35,7 +33,6 @@ def __init__( self.v = v self.tx_set = tx_set self.generalized_tx_set = generalized_tx_set - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -48,7 +45,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("generalized_tx_set should not be None.") self.generalized_tx_set.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> StoredTransactionSet: v = Integer.unpack(unpacker) @@ -59,7 +55,6 @@ def unpack(cls, unpacker: Unpacker) -> StoredTransactionSet: generalized_tx_set = GeneralizedTransactionSet.unpack(unpacker) return cls(v=v, generalized_tx_set=generalized_tx_set) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -78,30 +73,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> StoredTransactionSet: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.tx_set, - self.generalized_tx_set, - ) - ) - + return hash((self.v, self.tx_set, self.generalized_tx_set,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.v == other.v - and self.tx_set == other.tx_set - and self.generalized_tx_set == other.generalized_tx_set - ) - + return self.v== other.v and self.tx_set== other.tx_set and self.generalized_tx_set== other.generalized_tx_set def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"tx_set={self.tx_set}") if self.tx_set is not None else None - out.append( - f"generalized_tx_set={self.generalized_tx_set}" - ) if self.generalized_tx_set is not None else None + out.append(f'v={self.v}') + out.append(f'tx_set={self.tx_set}') if self.tx_set is not None else None + out.append(f'generalized_tx_set={self.generalized_tx_set}') if self.generalized_tx_set is not None else None return f"" diff --git a/stellar_sdk/xdr/string32.py b/stellar_sdk/xdr/string32.py index 386eb468..6661b216 100644 --- a/stellar_sdk/xdr/string32.py +++ b/stellar_sdk/xdr/string32.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import String - -__all__ = ["String32"] - - +__all__ = ['String32'] class String32: """ XDR Source Code:: typedef string string32<32>; """ - def __init__(self, string32: bytes) -> None: self.string32 = string32 - def pack(self, packer: Packer) -> None: String(self.string32, 32).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> String32: string32 = String.unpack(unpacker) return cls(string32) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> String32: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.string32) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/string64.py b/stellar_sdk/xdr/string64.py index 06248e56..56600d85 100644 --- a/stellar_sdk/xdr/string64.py +++ b/stellar_sdk/xdr/string64.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import String - -__all__ = ["String64"] - - +__all__ = ['String64'] class String64: """ XDR Source Code:: typedef string string64<64>; """ - def __init__(self, string64: bytes) -> None: self.string64 = string64 - def pack(self, packer: Packer) -> None: String(self.string64, 64).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> String64: string64 = String.unpack(unpacker) return cls(string64) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> String64: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.string64) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/survey_message_command_type.py b/stellar_sdk/xdr/survey_message_command_type.py index 635c7650..19bbabc9 100644 --- a/stellar_sdk/xdr/survey_message_command_type.py +++ b/stellar_sdk/xdr/survey_message_command_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SurveyMessageCommandType"] - - +__all__ = ['SurveyMessageCommandType'] class SurveyMessageCommandType(IntEnum): """ XDR Source Code:: @@ -19,9 +19,7 @@ class SurveyMessageCommandType(IntEnum): SURVEY_TOPOLOGY = 0 }; """ - SURVEY_TOPOLOGY = 0 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -29,7 +27,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SurveyMessageCommandType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/survey_message_response_type.py b/stellar_sdk/xdr/survey_message_response_type.py index 404683c3..5a23c24d 100644 --- a/stellar_sdk/xdr/survey_message_response_type.py +++ b/stellar_sdk/xdr/survey_message_response_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["SurveyMessageResponseType"] - - +__all__ = ['SurveyMessageResponseType'] class SurveyMessageResponseType(IntEnum): """ XDR Source Code:: @@ -20,10 +20,8 @@ class SurveyMessageResponseType(IntEnum): SURVEY_TOPOLOGY_RESPONSE_V1 = 1 }; """ - SURVEY_TOPOLOGY_RESPONSE_V0 = 0 SURVEY_TOPOLOGY_RESPONSE_V1 = 1 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> SurveyMessageResponseType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/survey_request_message.py b/stellar_sdk/xdr/survey_request_message.py index b5ddf130..a2a5bfaf 100644 --- a/stellar_sdk/xdr/survey_request_message.py +++ b/stellar_sdk/xdr/survey_request_message.py @@ -3,17 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .curve25519_public import Curve25519Public from .node_id import NodeID -from .survey_message_command_type import SurveyMessageCommandType +from .node_id import NodeID from .uint32 import Uint32 - -__all__ = ["SurveyRequestMessage"] - - +from .curve25519_public import Curve25519Public +from .survey_message_command_type import SurveyMessageCommandType +__all__ = ['SurveyRequestMessage'] class SurveyRequestMessage: """ XDR Source Code:: @@ -27,7 +28,6 @@ class SurveyRequestMessage: SurveyMessageCommandType commandType; }; """ - def __init__( self, surveyor_peer_id: NodeID, @@ -41,14 +41,12 @@ def __init__( self.ledger_num = ledger_num self.encryption_key = encryption_key self.command_type = command_type - def pack(self, packer: Packer) -> None: self.surveyor_peer_id.pack(packer) self.surveyed_peer_id.pack(packer) self.ledger_num.pack(packer) self.encryption_key.pack(packer) self.command_type.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SurveyRequestMessage: surveyor_peer_id = NodeID.unpack(unpacker) @@ -63,7 +61,6 @@ def unpack(cls, unpacker: Unpacker) -> SurveyRequestMessage: encryption_key=encryption_key, command_type=command_type, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -82,35 +79,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SurveyRequestMessage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.surveyor_peer_id, - self.surveyed_peer_id, - self.ledger_num, - self.encryption_key, - self.command_type, - ) - ) - + return hash((self.surveyor_peer_id, self.surveyed_peer_id, self.ledger_num, self.encryption_key, self.command_type,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.surveyor_peer_id == other.surveyor_peer_id - and self.surveyed_peer_id == other.surveyed_peer_id - and self.ledger_num == other.ledger_num - and self.encryption_key == other.encryption_key - and self.command_type == other.command_type - ) - + return self.surveyor_peer_id== other.surveyor_peer_id and self.surveyed_peer_id== other.surveyed_peer_id and self.ledger_num== other.ledger_num and self.encryption_key== other.encryption_key and self.command_type== other.command_type def __str__(self): out = [ - f"surveyor_peer_id={self.surveyor_peer_id}", - f"surveyed_peer_id={self.surveyed_peer_id}", - f"ledger_num={self.ledger_num}", - f"encryption_key={self.encryption_key}", - f"command_type={self.command_type}", + f'surveyor_peer_id={self.surveyor_peer_id}', + f'surveyed_peer_id={self.surveyed_peer_id}', + f'ledger_num={self.ledger_num}', + f'encryption_key={self.encryption_key}', + f'command_type={self.command_type}', ] return f"" diff --git a/stellar_sdk/xdr/survey_response_body.py b/stellar_sdk/xdr/survey_response_body.py index 42a15e0b..55bb616e 100644 --- a/stellar_sdk/xdr/survey_response_body.py +++ b/stellar_sdk/xdr/survey_response_body.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .survey_message_response_type import SurveyMessageResponseType from .topology_response_body_v0 import TopologyResponseBodyV0 from .topology_response_body_v1 import TopologyResponseBodyV1 - -__all__ = ["SurveyResponseBody"] - - +__all__ = ['SurveyResponseBody'] class SurveyResponseBody: """ XDR Source Code:: @@ -25,7 +25,6 @@ class SurveyResponseBody: TopologyResponseBodyV1 topologyResponseBodyV1; }; """ - def __init__( self, type: SurveyMessageResponseType, @@ -35,7 +34,6 @@ def __init__( self.type = type self.topology_response_body_v0 = topology_response_body_v0 self.topology_response_body_v1 = topology_response_body_v1 - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == SurveyMessageResponseType.SURVEY_TOPOLOGY_RESPONSE_V0: @@ -48,7 +46,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("topology_response_body_v1 should not be None.") self.topology_response_body_v1.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> SurveyResponseBody: type = SurveyMessageResponseType.unpack(unpacker) @@ -59,7 +56,6 @@ def unpack(cls, unpacker: Unpacker) -> SurveyResponseBody: topology_response_body_v1 = TopologyResponseBodyV1.unpack(unpacker) return cls(type=type, topology_response_body_v1=topology_response_body_v1) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -78,32 +74,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SurveyResponseBody: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.topology_response_body_v0, - self.topology_response_body_v1, - ) - ) - + return hash((self.type, self.topology_response_body_v0, self.topology_response_body_v1,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.topology_response_body_v0 == other.topology_response_body_v0 - and self.topology_response_body_v1 == other.topology_response_body_v1 - ) - + return self.type== other.type and self.topology_response_body_v0== other.topology_response_body_v0 and self.topology_response_body_v1== other.topology_response_body_v1 def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"topology_response_body_v0={self.topology_response_body_v0}" - ) if self.topology_response_body_v0 is not None else None - out.append( - f"topology_response_body_v1={self.topology_response_body_v1}" - ) if self.topology_response_body_v1 is not None else None + out.append(f'type={self.type}') + out.append(f'topology_response_body_v0={self.topology_response_body_v0}') if self.topology_response_body_v0 is not None else None + out.append(f'topology_response_body_v1={self.topology_response_body_v1}') if self.topology_response_body_v1 is not None else None return f"" diff --git a/stellar_sdk/xdr/survey_response_message.py b/stellar_sdk/xdr/survey_response_message.py index b80b229e..335c332b 100644 --- a/stellar_sdk/xdr/survey_response_message.py +++ b/stellar_sdk/xdr/survey_response_message.py @@ -3,17 +3,18 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .encrypted_body import EncryptedBody from .node_id import NodeID -from .survey_message_command_type import SurveyMessageCommandType +from .node_id import NodeID from .uint32 import Uint32 - -__all__ = ["SurveyResponseMessage"] - - +from .survey_message_command_type import SurveyMessageCommandType +from .encrypted_body import EncryptedBody +__all__ = ['SurveyResponseMessage'] class SurveyResponseMessage: """ XDR Source Code:: @@ -27,7 +28,6 @@ class SurveyResponseMessage: EncryptedBody encryptedBody; }; """ - def __init__( self, surveyor_peer_id: NodeID, @@ -41,14 +41,12 @@ def __init__( self.ledger_num = ledger_num self.command_type = command_type self.encrypted_body = encrypted_body - def pack(self, packer: Packer) -> None: self.surveyor_peer_id.pack(packer) self.surveyed_peer_id.pack(packer) self.ledger_num.pack(packer) self.command_type.pack(packer) self.encrypted_body.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> SurveyResponseMessage: surveyor_peer_id = NodeID.unpack(unpacker) @@ -63,7 +61,6 @@ def unpack(cls, unpacker: Unpacker) -> SurveyResponseMessage: command_type=command_type, encrypted_body=encrypted_body, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -82,35 +79,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> SurveyResponseMessage: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.surveyor_peer_id, - self.surveyed_peer_id, - self.ledger_num, - self.command_type, - self.encrypted_body, - ) - ) - + return hash((self.surveyor_peer_id, self.surveyed_peer_id, self.ledger_num, self.command_type, self.encrypted_body,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.surveyor_peer_id == other.surveyor_peer_id - and self.surveyed_peer_id == other.surveyed_peer_id - and self.ledger_num == other.ledger_num - and self.command_type == other.command_type - and self.encrypted_body == other.encrypted_body - ) - + return self.surveyor_peer_id== other.surveyor_peer_id and self.surveyed_peer_id== other.surveyed_peer_id and self.ledger_num== other.ledger_num and self.command_type== other.command_type and self.encrypted_body== other.encrypted_body def __str__(self): out = [ - f"surveyor_peer_id={self.surveyor_peer_id}", - f"surveyed_peer_id={self.surveyed_peer_id}", - f"ledger_num={self.ledger_num}", - f"command_type={self.command_type}", - f"encrypted_body={self.encrypted_body}", + f'surveyor_peer_id={self.surveyor_peer_id}', + f'surveyed_peer_id={self.surveyed_peer_id}', + f'ledger_num={self.ledger_num}', + f'command_type={self.command_type}', + f'encrypted_body={self.encrypted_body}', ] return f"" diff --git a/stellar_sdk/xdr/threshold_indexes.py b/stellar_sdk/xdr/threshold_indexes.py index 42858ac3..5a68356a 100644 --- a/stellar_sdk/xdr/threshold_indexes.py +++ b/stellar_sdk/xdr/threshold_indexes.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["ThresholdIndexes"] - - +__all__ = ['ThresholdIndexes'] class ThresholdIndexes(IntEnum): """ XDR Source Code:: @@ -22,12 +22,10 @@ class ThresholdIndexes(IntEnum): THRESHOLD_HIGH = 3 }; """ - THRESHOLD_MASTER_WEIGHT = 0 THRESHOLD_LOW = 1 THRESHOLD_MED = 2 THRESHOLD_HIGH = 3 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -35,7 +33,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> ThresholdIndexes: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/thresholds.py b/stellar_sdk/xdr/thresholds.py index 42860cf7..1f726fd4 100644 --- a/stellar_sdk/xdr/thresholds.py +++ b/stellar_sdk/xdr/thresholds.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["Thresholds"] - - +__all__ = ['Thresholds'] class Thresholds: """ XDR Source Code:: typedef opaque Thresholds[4]; """ - def __init__(self, thresholds: bytes) -> None: self.thresholds = thresholds - def pack(self, packer: Packer) -> None: Opaque(self.thresholds, 4, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Thresholds: thresholds = Opaque.unpack(unpacker, 4, True) return cls(thresholds) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Thresholds: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.thresholds) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/time_bounds.py b/stellar_sdk/xdr/time_bounds.py index 28238c59..258f361b 100644 --- a/stellar_sdk/xdr/time_bounds.py +++ b/stellar_sdk/xdr/time_bounds.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .time_point import TimePoint - -__all__ = ["TimeBounds"] - - +from .time_point import TimePoint +__all__ = ['TimeBounds'] class TimeBounds: """ XDR Source Code:: @@ -21,7 +22,6 @@ class TimeBounds: TimePoint maxTime; // 0 here means no maxTime }; """ - def __init__( self, min_time: TimePoint, @@ -29,11 +29,9 @@ def __init__( ) -> None: self.min_time = min_time self.max_time = max_time - def pack(self, packer: Packer) -> None: self.min_time.pack(packer) self.max_time.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TimeBounds: min_time = TimePoint.unpack(unpacker) @@ -42,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> TimeBounds: min_time=min_time, max_time=max_time, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -61,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TimeBounds: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.min_time, - self.max_time, - ) - ) - + return hash((self.min_time, self.max_time,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.min_time == other.min_time and self.max_time == other.max_time - + return self.min_time== other.min_time and self.max_time== other.max_time def __str__(self): out = [ - f"min_time={self.min_time}", - f"max_time={self.max_time}", + f'min_time={self.min_time}', + f'max_time={self.max_time}', ] return f"" diff --git a/stellar_sdk/xdr/time_point.py b/stellar_sdk/xdr/time_point.py index 07c61291..b165a926 100644 --- a/stellar_sdk/xdr/time_point.py +++ b/stellar_sdk/xdr/time_point.py @@ -3,32 +3,28 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint64 import Uint64 - -__all__ = ["TimePoint"] - - +__all__ = ['TimePoint'] class TimePoint: """ XDR Source Code:: typedef uint64 TimePoint; """ - def __init__(self, time_point: Uint64) -> None: self.time_point = time_point - def pack(self, packer: Packer) -> None: self.time_point.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TimePoint: time_point = Uint64.unpack(unpacker) return cls(time_point) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +43,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TimePoint: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.time_point) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/topology_response_body_v0.py b/stellar_sdk/xdr/topology_response_body_v0.py index bbdc3898..3820bcd1 100644 --- a/stellar_sdk/xdr/topology_response_body_v0.py +++ b/stellar_sdk/xdr/topology_response_body_v0.py @@ -3,15 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .peer_stat_list import PeerStatList from .peer_stat_list import PeerStatList from .uint32 import Uint32 - -__all__ = ["TopologyResponseBodyV0"] - - +from .uint32 import Uint32 +__all__ = ['TopologyResponseBodyV0'] class TopologyResponseBodyV0: """ XDR Source Code:: @@ -25,7 +27,6 @@ class TopologyResponseBodyV0: uint32 totalOutboundPeerCount; }; """ - def __init__( self, inbound_peers: PeerStatList, @@ -37,13 +38,11 @@ def __init__( self.outbound_peers = outbound_peers self.total_inbound_peer_count = total_inbound_peer_count self.total_outbound_peer_count = total_outbound_peer_count - def pack(self, packer: Packer) -> None: self.inbound_peers.pack(packer) self.outbound_peers.pack(packer) self.total_inbound_peer_count.pack(packer) self.total_outbound_peer_count.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TopologyResponseBodyV0: inbound_peers = PeerStatList.unpack(unpacker) @@ -56,7 +55,6 @@ def unpack(cls, unpacker: Unpacker) -> TopologyResponseBodyV0: total_inbound_peer_count=total_inbound_peer_count, total_outbound_peer_count=total_outbound_peer_count, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -75,32 +73,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TopologyResponseBodyV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.inbound_peers, - self.outbound_peers, - self.total_inbound_peer_count, - self.total_outbound_peer_count, - ) - ) - + return hash((self.inbound_peers, self.outbound_peers, self.total_inbound_peer_count, self.total_outbound_peer_count,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.inbound_peers == other.inbound_peers - and self.outbound_peers == other.outbound_peers - and self.total_inbound_peer_count == other.total_inbound_peer_count - and self.total_outbound_peer_count == other.total_outbound_peer_count - ) - + return self.inbound_peers== other.inbound_peers and self.outbound_peers== other.outbound_peers and self.total_inbound_peer_count== other.total_inbound_peer_count and self.total_outbound_peer_count== other.total_outbound_peer_count def __str__(self): out = [ - f"inbound_peers={self.inbound_peers}", - f"outbound_peers={self.outbound_peers}", - f"total_inbound_peer_count={self.total_inbound_peer_count}", - f"total_outbound_peer_count={self.total_outbound_peer_count}", + f'inbound_peers={self.inbound_peers}', + f'outbound_peers={self.outbound_peers}', + f'total_inbound_peer_count={self.total_inbound_peer_count}', + f'total_outbound_peer_count={self.total_outbound_peer_count}', ] return f"" diff --git a/stellar_sdk/xdr/topology_response_body_v1.py b/stellar_sdk/xdr/topology_response_body_v1.py index c9c72ffc..9a6783b0 100644 --- a/stellar_sdk/xdr/topology_response_body_v1.py +++ b/stellar_sdk/xdr/topology_response_body_v1.py @@ -3,15 +3,19 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .peer_stat_list import PeerStatList from .peer_stat_list import PeerStatList from .uint32 import Uint32 - -__all__ = ["TopologyResponseBodyV1"] - - +from .uint32 import Uint32 +from .uint32 import Uint32 +from .uint32 import Uint32 +__all__ = ['TopologyResponseBodyV1'] class TopologyResponseBodyV1: """ XDR Source Code:: @@ -28,7 +32,6 @@ class TopologyResponseBodyV1: uint32 maxOutboundPeerCount; }; """ - def __init__( self, inbound_peers: PeerStatList, @@ -44,7 +47,6 @@ def __init__( self.total_outbound_peer_count = total_outbound_peer_count self.max_inbound_peer_count = max_inbound_peer_count self.max_outbound_peer_count = max_outbound_peer_count - def pack(self, packer: Packer) -> None: self.inbound_peers.pack(packer) self.outbound_peers.pack(packer) @@ -52,7 +54,6 @@ def pack(self, packer: Packer) -> None: self.total_outbound_peer_count.pack(packer) self.max_inbound_peer_count.pack(packer) self.max_outbound_peer_count.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TopologyResponseBodyV1: inbound_peers = PeerStatList.unpack(unpacker) @@ -69,7 +70,6 @@ def unpack(cls, unpacker: Unpacker) -> TopologyResponseBodyV1: max_inbound_peer_count=max_inbound_peer_count, max_outbound_peer_count=max_outbound_peer_count, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -88,38 +88,19 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TopologyResponseBodyV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.inbound_peers, - self.outbound_peers, - self.total_inbound_peer_count, - self.total_outbound_peer_count, - self.max_inbound_peer_count, - self.max_outbound_peer_count, - ) - ) - + return hash((self.inbound_peers, self.outbound_peers, self.total_inbound_peer_count, self.total_outbound_peer_count, self.max_inbound_peer_count, self.max_outbound_peer_count,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.inbound_peers == other.inbound_peers - and self.outbound_peers == other.outbound_peers - and self.total_inbound_peer_count == other.total_inbound_peer_count - and self.total_outbound_peer_count == other.total_outbound_peer_count - and self.max_inbound_peer_count == other.max_inbound_peer_count - and self.max_outbound_peer_count == other.max_outbound_peer_count - ) - + return self.inbound_peers== other.inbound_peers and self.outbound_peers== other.outbound_peers and self.total_inbound_peer_count== other.total_inbound_peer_count and self.total_outbound_peer_count== other.total_outbound_peer_count and self.max_inbound_peer_count== other.max_inbound_peer_count and self.max_outbound_peer_count== other.max_outbound_peer_count def __str__(self): out = [ - f"inbound_peers={self.inbound_peers}", - f"outbound_peers={self.outbound_peers}", - f"total_inbound_peer_count={self.total_inbound_peer_count}", - f"total_outbound_peer_count={self.total_outbound_peer_count}", - f"max_inbound_peer_count={self.max_inbound_peer_count}", - f"max_outbound_peer_count={self.max_outbound_peer_count}", + f'inbound_peers={self.inbound_peers}', + f'outbound_peers={self.outbound_peers}', + f'total_inbound_peer_count={self.total_inbound_peer_count}', + f'total_outbound_peer_count={self.total_outbound_peer_count}', + f'max_inbound_peer_count={self.max_inbound_peer_count}', + f'max_outbound_peer_count={self.max_outbound_peer_count}', ] return f"" diff --git a/stellar_sdk/xdr/transaction.py b/stellar_sdk/xdr/transaction.py index bdb0a187..d60ccbe3 100644 --- a/stellar_sdk/xdr/transaction.py +++ b/stellar_sdk/xdr/transaction.py @@ -3,22 +3,20 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .memo import Memo + from .muxed_account import MuxedAccount -from .operation import Operation -from .preconditions import Preconditions +from .uint32 import Uint32 from .sequence_number import SequenceNumber +from .preconditions import Preconditions +from .memo import Memo +from .operation import Operation from .transaction_ext import TransactionExt -from .uint32 import Uint32 - -__all__ = ["Transaction"] - - +__all__ = ['Transaction'] class Transaction: """ XDR Source Code:: @@ -52,7 +50,6 @@ class Transaction: ext; }; """ - def __init__( self, source_account: MuxedAccount, @@ -65,9 +62,7 @@ def __init__( ) -> None: _expect_max_length = MAX_OPS_PER_TX if operations and len(operations) > _expect_max_length: - raise ValueError( - f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}." - ) + raise ValueError(f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}.") self.source_account = source_account self.fee = fee self.seq_num = seq_num @@ -75,7 +70,6 @@ def __init__( self.memo = memo self.operations = operations self.ext = ext - def pack(self, packer: Packer) -> None: self.source_account.pack(packer) self.fee.pack(packer) @@ -86,7 +80,6 @@ def pack(self, packer: Packer) -> None: for operations_item in self.operations: operations_item.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Transaction: source_account = MuxedAccount.unpack(unpacker) @@ -108,7 +101,6 @@ def unpack(cls, unpacker: Unpacker) -> Transaction: operations=operations, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -127,41 +119,20 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Transaction: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.source_account, - self.fee, - self.seq_num, - self.cond, - self.memo, - self.operations, - self.ext, - ) - ) - + return hash((self.source_account, self.fee, self.seq_num, self.cond, self.memo, self.operations, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.source_account == other.source_account - and self.fee == other.fee - and self.seq_num == other.seq_num - and self.cond == other.cond - and self.memo == other.memo - and self.operations == other.operations - and self.ext == other.ext - ) - + return self.source_account== other.source_account and self.fee== other.fee and self.seq_num== other.seq_num and self.cond== other.cond and self.memo== other.memo and self.operations== other.operations and self.ext== other.ext def __str__(self): out = [ - f"source_account={self.source_account}", - f"fee={self.fee}", - f"seq_num={self.seq_num}", - f"cond={self.cond}", - f"memo={self.memo}", - f"operations={self.operations}", - f"ext={self.ext}", + f'source_account={self.source_account}', + f'fee={self.fee}', + f'seq_num={self.seq_num}', + f'cond={self.cond}', + f'memo={self.memo}', + f'operations={self.operations}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_envelope.py b/stellar_sdk/xdr/transaction_envelope.py index 977438c5..2785880e 100644 --- a/stellar_sdk/xdr/transaction_envelope.py +++ b/stellar_sdk/xdr/transaction_envelope.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .envelope_type import EnvelopeType -from .fee_bump_transaction_envelope import FeeBumpTransactionEnvelope from .transaction_v0_envelope import TransactionV0Envelope from .transaction_v1_envelope import TransactionV1Envelope - -__all__ = ["TransactionEnvelope"] - - +from .fee_bump_transaction_envelope import FeeBumpTransactionEnvelope +__all__ = ['TransactionEnvelope'] class TransactionEnvelope: """ XDR Source Code:: @@ -28,7 +28,6 @@ class TransactionEnvelope: FeeBumpTransactionEnvelope feeBump; }; """ - def __init__( self, type: EnvelopeType, @@ -40,7 +39,6 @@ def __init__( self.v0 = v0 self.v1 = v1 self.fee_bump = fee_bump - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == EnvelopeType.ENVELOPE_TYPE_TX_V0: @@ -58,7 +56,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("fee_bump should not be None.") self.fee_bump.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionEnvelope: type = EnvelopeType.unpack(unpacker) @@ -72,7 +69,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionEnvelope: fee_bump = FeeBumpTransactionEnvelope.unpack(unpacker) return cls(type=type, fee_bump=fee_bump) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -91,31 +87,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionEnvelope: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.v0, - self.v1, - self.fee_bump, - ) - ) - + return hash((self.type, self.v0, self.v1, self.fee_bump,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.v0 == other.v0 - and self.v1 == other.v1 - and self.fee_bump == other.fee_bump - ) - + return self.type== other.type and self.v0== other.v0 and self.v1== other.v1 and self.fee_bump== other.fee_bump def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"v0={self.v0}") if self.v0 is not None else None - out.append(f"v1={self.v1}") if self.v1 is not None else None - out.append(f"fee_bump={self.fee_bump}") if self.fee_bump is not None else None + out.append(f'type={self.type}') + out.append(f'v0={self.v0}') if self.v0 is not None else None + out.append(f'v1={self.v1}') if self.v1 is not None else None + out.append(f'fee_bump={self.fee_bump}') if self.fee_bump is not None else None return f"" diff --git a/stellar_sdk/xdr/transaction_ext.py b/stellar_sdk/xdr/transaction_ext.py index f2842472..7013fe54 100644 --- a/stellar_sdk/xdr/transaction_ext.py +++ b/stellar_sdk/xdr/transaction_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .soroban_transaction_data import SorobanTransactionData - -__all__ = ["TransactionExt"] - - +__all__ = ['TransactionExt'] class TransactionExt: """ XDR Source Code:: @@ -24,7 +23,6 @@ class TransactionExt: SorobanTransactionData sorobanData; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.soroban_data = soroban_data - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("soroban_data should not be None.") self.soroban_data.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionExt: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionExt: soroban_data = SorobanTransactionData.unpack(unpacker) return cls(v=v, soroban_data=soroban_data) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,24 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.soroban_data, - ) - ) - + return hash((self.v, self.soroban_data,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.soroban_data == other.soroban_data - + return self.v== other.v and self.soroban_data== other.soroban_data def __str__(self): out = [] - out.append(f"v={self.v}") - out.append( - f"soroban_data={self.soroban_data}" - ) if self.soroban_data is not None else None + out.append(f'v={self.v}') + out.append(f'soroban_data={self.soroban_data}') if self.soroban_data is not None else None return f"" diff --git a/stellar_sdk/xdr/transaction_history_entry.py b/stellar_sdk/xdr/transaction_history_entry.py index 58ad6140..c2f731cd 100644 --- a/stellar_sdk/xdr/transaction_history_entry.py +++ b/stellar_sdk/xdr/transaction_history_entry.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .transaction_history_entry_ext import TransactionHistoryEntryExt -from .transaction_set import TransactionSet from .uint32 import Uint32 - -__all__ = ["TransactionHistoryEntry"] - - +from .transaction_set import TransactionSet +from .transaction_history_entry_ext import TransactionHistoryEntryExt +__all__ = ['TransactionHistoryEntry'] class TransactionHistoryEntry: """ XDR Source Code:: @@ -33,7 +33,6 @@ class TransactionHistoryEntry: ext; }; """ - def __init__( self, ledger_seq: Uint32, @@ -43,12 +42,10 @@ def __init__( self.ledger_seq = ledger_seq self.tx_set = tx_set self.ext = ext - def pack(self, packer: Packer) -> None: self.ledger_seq.pack(packer) self.tx_set.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionHistoryEntry: ledger_seq = Uint32.unpack(unpacker) @@ -59,7 +56,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionHistoryEntry: tx_set=tx_set, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -78,29 +74,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionHistoryEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_seq, - self.tx_set, - self.ext, - ) - ) - + return hash((self.ledger_seq, self.tx_set, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_seq == other.ledger_seq - and self.tx_set == other.tx_set - and self.ext == other.ext - ) - + return self.ledger_seq== other.ledger_seq and self.tx_set== other.tx_set and self.ext== other.ext def __str__(self): out = [ - f"ledger_seq={self.ledger_seq}", - f"tx_set={self.tx_set}", - f"ext={self.ext}", + f'ledger_seq={self.ledger_seq}', + f'tx_set={self.tx_set}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_history_entry_ext.py b/stellar_sdk/xdr/transaction_history_entry_ext.py index f0d0a92e..ec46f9fb 100644 --- a/stellar_sdk/xdr/transaction_history_entry_ext.py +++ b/stellar_sdk/xdr/transaction_history_entry_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .generalized_transaction_set import GeneralizedTransactionSet - -__all__ = ["TransactionHistoryEntryExt"] - - +__all__ = ['TransactionHistoryEntryExt'] class TransactionHistoryEntryExt: """ XDR Source Code:: @@ -24,7 +23,6 @@ class TransactionHistoryEntryExt: GeneralizedTransactionSet generalizedTxSet; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.generalized_tx_set = generalized_tx_set - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("generalized_tx_set should not be None.") self.generalized_tx_set.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionHistoryEntryExt: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionHistoryEntryExt: generalized_tx_set = GeneralizedTransactionSet.unpack(unpacker) return cls(v=v, generalized_tx_set=generalized_tx_set) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,24 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionHistoryEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.generalized_tx_set, - ) - ) - + return hash((self.v, self.generalized_tx_set,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.generalized_tx_set == other.generalized_tx_set - + return self.v== other.v and self.generalized_tx_set== other.generalized_tx_set def __str__(self): out = [] - out.append(f"v={self.v}") - out.append( - f"generalized_tx_set={self.generalized_tx_set}" - ) if self.generalized_tx_set is not None else None + out.append(f'v={self.v}') + out.append(f'generalized_tx_set={self.generalized_tx_set}') if self.generalized_tx_set is not None else None return f"" diff --git a/stellar_sdk/xdr/transaction_history_result_entry.py b/stellar_sdk/xdr/transaction_history_result_entry.py index 17e3e7a9..7c3f89ca 100644 --- a/stellar_sdk/xdr/transaction_history_result_entry.py +++ b/stellar_sdk/xdr/transaction_history_result_entry.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .transaction_history_result_entry_ext import TransactionHistoryResultEntryExt -from .transaction_result_set import TransactionResultSet from .uint32 import Uint32 - -__all__ = ["TransactionHistoryResultEntry"] - - +from .transaction_result_set import TransactionResultSet +from .transaction_history_result_entry_ext import TransactionHistoryResultEntryExt +__all__ = ['TransactionHistoryResultEntry'] class TransactionHistoryResultEntry: """ XDR Source Code:: @@ -31,7 +31,6 @@ class TransactionHistoryResultEntry: ext; }; """ - def __init__( self, ledger_seq: Uint32, @@ -41,12 +40,10 @@ def __init__( self.ledger_seq = ledger_seq self.tx_result_set = tx_result_set self.ext = ext - def pack(self, packer: Packer) -> None: self.ledger_seq.pack(packer) self.tx_result_set.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionHistoryResultEntry: ledger_seq = Uint32.unpack(unpacker) @@ -57,7 +54,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionHistoryResultEntry: tx_result_set=tx_result_set, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -76,29 +72,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionHistoryResultEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ledger_seq, - self.tx_result_set, - self.ext, - ) - ) - + return hash((self.ledger_seq, self.tx_result_set, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ledger_seq == other.ledger_seq - and self.tx_result_set == other.tx_result_set - and self.ext == other.ext - ) - + return self.ledger_seq== other.ledger_seq and self.tx_result_set== other.tx_result_set and self.ext== other.ext def __str__(self): out = [ - f"ledger_seq={self.ledger_seq}", - f"tx_result_set={self.tx_result_set}", - f"ext={self.ext}", + f'ledger_seq={self.ledger_seq}', + f'tx_result_set={self.tx_result_set}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_history_result_entry_ext.py b/stellar_sdk/xdr/transaction_history_result_entry_ext.py index e90aa656..e15f03cc 100644 --- a/stellar_sdk/xdr/transaction_history_result_entry_ext.py +++ b/stellar_sdk/xdr/transaction_history_result_entry_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["TransactionHistoryResultEntryExt"] - - +__all__ = ['TransactionHistoryResultEntryExt'] class TransactionHistoryResultEntryExt: """ XDR Source Code:: @@ -21,25 +20,21 @@ class TransactionHistoryResultEntryExt: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionHistoryResultEntryExt: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionHistoryResultEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/transaction_meta.py b/stellar_sdk/xdr/transaction_meta.py index 0c2cc5f4..8288beff 100644 --- a/stellar_sdk/xdr/transaction_meta.py +++ b/stellar_sdk/xdr/transaction_meta.py @@ -3,19 +3,17 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .operation_meta import OperationMeta from .transaction_meta_v1 import TransactionMetaV1 from .transaction_meta_v2 import TransactionMetaV2 from .transaction_meta_v3 import TransactionMetaV3 - -__all__ = ["TransactionMeta"] - - +__all__ = ['TransactionMeta'] class TransactionMeta: """ XDR Source Code:: @@ -32,7 +30,6 @@ class TransactionMeta: TransactionMetaV3 v3; }; """ - def __init__( self, v: int, @@ -43,15 +40,12 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if operations and len(operations) > _expect_max_length: - raise ValueError( - f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}." - ) + raise ValueError(f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}.") self.v = v self.operations = operations self.v1 = v1 self.v2 = v2 self.v3 = v3 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -76,7 +70,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v3 should not be None.") self.v3.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionMeta: v = Integer.unpack(unpacker) @@ -96,7 +89,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionMeta: v3 = TransactionMetaV3.unpack(unpacker) return cls(v=v, v3=v3) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -115,36 +107,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionMeta: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.operations, - self.v1, - self.v2, - self.v3, - ) - ) - + return hash((self.v, self.operations, self.v1, self.v2, self.v3,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.v == other.v - and self.operations == other.operations - and self.v1 == other.v1 - and self.v2 == other.v2 - and self.v3 == other.v3 - ) - + return self.v== other.v and self.operations== other.operations and self.v1== other.v1 and self.v2== other.v2 and self.v3== other.v3 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append( - f"operations={self.operations}" - ) if self.operations is not None else None - out.append(f"v1={self.v1}") if self.v1 is not None else None - out.append(f"v2={self.v2}") if self.v2 is not None else None - out.append(f"v3={self.v3}") if self.v3 is not None else None + out.append(f'v={self.v}') + out.append(f'operations={self.operations}') if self.operations is not None else None + out.append(f'v1={self.v1}') if self.v1 is not None else None + out.append(f'v2={self.v2}') if self.v2 is not None else None + out.append(f'v3={self.v3}') if self.v3 is not None else None return f"" diff --git a/stellar_sdk/xdr/transaction_meta_v1.py b/stellar_sdk/xdr/transaction_meta_v1.py index 25001752..4d6cb27d 100644 --- a/stellar_sdk/xdr/transaction_meta_v1.py +++ b/stellar_sdk/xdr/transaction_meta_v1.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .ledger_entry_changes import LedgerEntryChanges from .operation_meta import OperationMeta - -__all__ = ["TransactionMetaV1"] - - +__all__ = ['TransactionMetaV1'] class TransactionMetaV1: """ XDR Source Code:: @@ -23,7 +22,6 @@ class TransactionMetaV1: OperationMeta operations<>; // meta for each operation }; """ - def __init__( self, tx_changes: LedgerEntryChanges, @@ -31,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if operations and len(operations) > _expect_max_length: - raise ValueError( - f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}." - ) + raise ValueError(f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}.") self.tx_changes = tx_changes self.operations = operations - def pack(self, packer: Packer) -> None: self.tx_changes.pack(packer) packer.pack_uint(len(self.operations)) for operations_item in self.operations: operations_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionMetaV1: tx_changes = LedgerEntryChanges.unpack(unpacker) @@ -54,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionMetaV1: tx_changes=tx_changes, operations=operations, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,25 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionMetaV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.tx_changes, - self.operations, - ) - ) - + return hash((self.tx_changes, self.operations,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.tx_changes == other.tx_changes and self.operations == other.operations - ) - + return self.tx_changes== other.tx_changes and self.operations== other.operations def __str__(self): out = [ - f"tx_changes={self.tx_changes}", - f"operations={self.operations}", + f'tx_changes={self.tx_changes}', + f'operations={self.operations}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_meta_v2.py b/stellar_sdk/xdr/transaction_meta_v2.py index 1aae1054..a8756914 100644 --- a/stellar_sdk/xdr/transaction_meta_v2.py +++ b/stellar_sdk/xdr/transaction_meta_v2.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .ledger_entry_changes import LedgerEntryChanges from .operation_meta import OperationMeta - -__all__ = ["TransactionMetaV2"] - - +from .ledger_entry_changes import LedgerEntryChanges +__all__ = ['TransactionMetaV2'] class TransactionMetaV2: """ XDR Source Code:: @@ -26,7 +26,6 @@ class TransactionMetaV2: // applied if any }; """ - def __init__( self, tx_changes_before: LedgerEntryChanges, @@ -35,20 +34,16 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if operations and len(operations) > _expect_max_length: - raise ValueError( - f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}." - ) + raise ValueError(f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}.") self.tx_changes_before = tx_changes_before self.operations = operations self.tx_changes_after = tx_changes_after - def pack(self, packer: Packer) -> None: self.tx_changes_before.pack(packer) packer.pack_uint(len(self.operations)) for operations_item in self.operations: operations_item.pack(packer) self.tx_changes_after.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionMetaV2: tx_changes_before = LedgerEntryChanges.unpack(unpacker) @@ -62,7 +57,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionMetaV2: operations=operations, tx_changes_after=tx_changes_after, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -81,29 +75,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionMetaV2: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.tx_changes_before, - self.operations, - self.tx_changes_after, - ) - ) - + return hash((self.tx_changes_before, self.operations, self.tx_changes_after,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.tx_changes_before == other.tx_changes_before - and self.operations == other.operations - and self.tx_changes_after == other.tx_changes_after - ) - + return self.tx_changes_before== other.tx_changes_before and self.operations== other.operations and self.tx_changes_after== other.tx_changes_after def __str__(self): out = [ - f"tx_changes_before={self.tx_changes_before}", - f"operations={self.operations}", - f"tx_changes_after={self.tx_changes_after}", + f'tx_changes_before={self.tx_changes_before}', + f'operations={self.operations}', + f'tx_changes_after={self.tx_changes_after}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_meta_v3.py b/stellar_sdk/xdr/transaction_meta_v3.py index 547052c0..765d57b1 100644 --- a/stellar_sdk/xdr/transaction_meta_v3.py +++ b/stellar_sdk/xdr/transaction_meta_v3.py @@ -3,18 +3,18 @@ from __future__ import annotations import base64 -from typing import List, Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .extension_point import ExtensionPoint from .ledger_entry_changes import LedgerEntryChanges from .operation_meta import OperationMeta +from .ledger_entry_changes import LedgerEntryChanges from .soroban_transaction_meta import SorobanTransactionMeta - -__all__ = ["TransactionMetaV3"] - - +__all__ = ['TransactionMetaV3'] class TransactionMetaV3: """ XDR Source Code:: @@ -28,11 +28,10 @@ class TransactionMetaV3: OperationMeta operations<>; // meta for each operation LedgerEntryChanges txChangesAfter; // tx level changes after operations are // applied if any - SorobanTransactionMeta* sorobanMeta; // Soroban-specific meta (only for + SorobanTransactionMeta* sorobanMeta; // Soroban-specific meta (only for // Soroban transactions). }; """ - def __init__( self, ext: ExtensionPoint, @@ -43,15 +42,12 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if operations and len(operations) > _expect_max_length: - raise ValueError( - f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}." - ) + raise ValueError(f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}.") self.ext = ext self.tx_changes_before = tx_changes_before self.operations = operations self.tx_changes_after = tx_changes_after self.soroban_meta = soroban_meta - def pack(self, packer: Packer) -> None: self.ext.pack(packer) self.tx_changes_before.pack(packer) @@ -64,7 +60,6 @@ def pack(self, packer: Packer) -> None: else: packer.pack_uint(1) self.soroban_meta.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionMetaV3: ext = ExtensionPoint.unpack(unpacker) @@ -74,9 +69,7 @@ def unpack(cls, unpacker: Unpacker) -> TransactionMetaV3: for _ in range(length): operations.append(OperationMeta.unpack(unpacker)) tx_changes_after = LedgerEntryChanges.unpack(unpacker) - soroban_meta = ( - SorobanTransactionMeta.unpack(unpacker) if unpacker.unpack_uint() else None - ) + soroban_meta = SorobanTransactionMeta.unpack(unpacker) if unpacker.unpack_uint() else None return cls( ext=ext, tx_changes_before=tx_changes_before, @@ -84,7 +77,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionMetaV3: tx_changes_after=tx_changes_after, soroban_meta=soroban_meta, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -103,35 +95,18 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionMetaV3: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.ext, - self.tx_changes_before, - self.operations, - self.tx_changes_after, - self.soroban_meta, - ) - ) - + return hash((self.ext, self.tx_changes_before, self.operations, self.tx_changes_after, self.soroban_meta,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.ext == other.ext - and self.tx_changes_before == other.tx_changes_before - and self.operations == other.operations - and self.tx_changes_after == other.tx_changes_after - and self.soroban_meta == other.soroban_meta - ) - + return self.ext== other.ext and self.tx_changes_before== other.tx_changes_before and self.operations== other.operations and self.tx_changes_after== other.tx_changes_after and self.soroban_meta== other.soroban_meta def __str__(self): out = [ - f"ext={self.ext}", - f"tx_changes_before={self.tx_changes_before}", - f"operations={self.operations}", - f"tx_changes_after={self.tx_changes_after}", - f"soroban_meta={self.soroban_meta}", + f'ext={self.ext}', + f'tx_changes_before={self.tx_changes_before}', + f'operations={self.operations}', + f'tx_changes_after={self.tx_changes_after}', + f'soroban_meta={self.soroban_meta}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_phase.py b/stellar_sdk/xdr/transaction_phase.py index cf67bc51..5eb57d95 100644 --- a/stellar_sdk/xdr/transaction_phase.py +++ b/stellar_sdk/xdr/transaction_phase.py @@ -3,16 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .tx_set_component import TxSetComponent - -__all__ = ["TransactionPhase"] - - +__all__ = ['TransactionPhase'] class TransactionPhase: """ XDR Source Code:: @@ -23,7 +21,6 @@ class TransactionPhase: TxSetComponent v0Components<>; }; """ - def __init__( self, v: int, @@ -31,12 +28,9 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if v0_components and len(v0_components) > _expect_max_length: - raise ValueError( - f"The maximum length of `v0_components` should be {_expect_max_length}, but got {len(v0_components)}." - ) + raise ValueError(f"The maximum length of `v0_components` should be {_expect_max_length}, but got {len(v0_components)}.") self.v = v self.v0_components = v0_components - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -46,7 +40,6 @@ def pack(self, packer: Packer) -> None: for v0_components_item in self.v0_components: v0_components_item.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionPhase: v = Integer.unpack(unpacker) @@ -57,7 +50,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionPhase: v0_components.append(TxSetComponent.unpack(unpacker)) return cls(v=v, v0_components=v0_components) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -76,24 +68,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionPhase: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v0_components, - ) - ) - + return hash((self.v, self.v0_components,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v0_components == other.v0_components - + return self.v== other.v and self.v0_components== other.v0_components def __str__(self): out = [] - out.append(f"v={self.v}") - out.append( - f"v0_components={self.v0_components}" - ) if self.v0_components is not None else None + out.append(f'v={self.v}') + out.append(f'v0_components={self.v0_components}') if self.v0_components is not None else None return f"" diff --git a/stellar_sdk/xdr/transaction_result.py b/stellar_sdk/xdr/transaction_result.py index 40372275..2ee64c0a 100644 --- a/stellar_sdk/xdr/transaction_result.py +++ b/stellar_sdk/xdr/transaction_result.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int64 import Int64 -from .transaction_result_ext import TransactionResultExt from .transaction_result_result import TransactionResultResult - -__all__ = ["TransactionResult"] - - +from .transaction_result_ext import TransactionResultExt +__all__ = ['TransactionResult'] class TransactionResult: """ XDR Source Code:: @@ -58,7 +58,6 @@ class TransactionResult: ext; }; """ - def __init__( self, fee_charged: Int64, @@ -68,12 +67,10 @@ def __init__( self.fee_charged = fee_charged self.result = result self.ext = ext - def pack(self, packer: Packer) -> None: self.fee_charged.pack(packer) self.result.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionResult: fee_charged = Int64.unpack(unpacker) @@ -84,7 +81,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionResult: result=result, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -103,29 +99,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.fee_charged, - self.result, - self.ext, - ) - ) - + return hash((self.fee_charged, self.result, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.fee_charged == other.fee_charged - and self.result == other.result - and self.ext == other.ext - ) - + return self.fee_charged== other.fee_charged and self.result== other.result and self.ext== other.ext def __str__(self): out = [ - f"fee_charged={self.fee_charged}", - f"result={self.result}", - f"ext={self.ext}", + f'fee_charged={self.fee_charged}', + f'result={self.result}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_result_code.py b/stellar_sdk/xdr/transaction_result_code.py index 0c88a6df..47076099 100644 --- a/stellar_sdk/xdr/transaction_result_code.py +++ b/stellar_sdk/xdr/transaction_result_code.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["TransactionResultCode"] - - +__all__ = ['TransactionResultCode'] class TransactionResultCode(IntEnum): """ XDR Source Code:: @@ -41,7 +41,6 @@ class TransactionResultCode(IntEnum): txSOROBAN_INVALID = -17 // soroban-specific preconditions were not met }; """ - txFEE_BUMP_INNER_SUCCESS = 1 txSUCCESS = 0 txFAILED = -1 @@ -61,7 +60,6 @@ class TransactionResultCode(IntEnum): txBAD_MIN_SEQ_AGE_OR_GAP = -15 txMALFORMED = -16 txSOROBAN_INVALID = -17 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -69,7 +67,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> TransactionResultCode: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/transaction_result_ext.py b/stellar_sdk/xdr/transaction_result_ext.py index 81078c6f..525b9cc0 100644 --- a/stellar_sdk/xdr/transaction_result_ext.py +++ b/stellar_sdk/xdr/transaction_result_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["TransactionResultExt"] - - +__all__ = ['TransactionResultExt'] class TransactionResultExt: """ XDR Source Code:: @@ -21,25 +20,21 @@ class TransactionResultExt: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionResultExt: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionResultExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/transaction_result_meta.py b/stellar_sdk/xdr/transaction_result_meta.py index dc9aa635..0caa6fe2 100644 --- a/stellar_sdk/xdr/transaction_result_meta.py +++ b/stellar_sdk/xdr/transaction_result_meta.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .transaction_result_pair import TransactionResultPair from .ledger_entry_changes import LedgerEntryChanges from .transaction_meta import TransactionMeta -from .transaction_result_pair import TransactionResultPair - -__all__ = ["TransactionResultMeta"] - - +__all__ = ['TransactionResultMeta'] class TransactionResultMeta: """ XDR Source Code:: @@ -24,7 +24,6 @@ class TransactionResultMeta: TransactionMeta txApplyProcessing; }; """ - def __init__( self, result: TransactionResultPair, @@ -34,12 +33,10 @@ def __init__( self.result = result self.fee_processing = fee_processing self.tx_apply_processing = tx_apply_processing - def pack(self, packer: Packer) -> None: self.result.pack(packer) self.fee_processing.pack(packer) self.tx_apply_processing.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionResultMeta: result = TransactionResultPair.unpack(unpacker) @@ -50,7 +47,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionResultMeta: fee_processing=fee_processing, tx_apply_processing=tx_apply_processing, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -69,29 +65,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionResultMeta: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.result, - self.fee_processing, - self.tx_apply_processing, - ) - ) - + return hash((self.result, self.fee_processing, self.tx_apply_processing,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.result == other.result - and self.fee_processing == other.fee_processing - and self.tx_apply_processing == other.tx_apply_processing - ) - + return self.result== other.result and self.fee_processing== other.fee_processing and self.tx_apply_processing== other.tx_apply_processing def __str__(self): out = [ - f"result={self.result}", - f"fee_processing={self.fee_processing}", - f"tx_apply_processing={self.tx_apply_processing}", + f'result={self.result}', + f'fee_processing={self.fee_processing}', + f'tx_apply_processing={self.tx_apply_processing}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_result_pair.py b/stellar_sdk/xdr/transaction_result_pair.py index 93fe0122..fb9b5ff2 100644 --- a/stellar_sdk/xdr/transaction_result_pair.py +++ b/stellar_sdk/xdr/transaction_result_pair.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash from .transaction_result import TransactionResult - -__all__ = ["TransactionResultPair"] - - +__all__ = ['TransactionResultPair'] class TransactionResultPair: """ XDR Source Code:: @@ -22,7 +22,6 @@ class TransactionResultPair: TransactionResult result; // result for the transaction }; """ - def __init__( self, transaction_hash: Hash, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.transaction_hash = transaction_hash self.result = result - def pack(self, packer: Packer) -> None: self.transaction_hash.pack(packer) self.result.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionResultPair: transaction_hash = Hash.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionResultPair: transaction_hash=transaction_hash, result=result, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,26 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionResultPair: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.transaction_hash, - self.result, - ) - ) - + return hash((self.transaction_hash, self.result,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.transaction_hash == other.transaction_hash - and self.result == other.result - ) - + return self.transaction_hash== other.transaction_hash and self.result== other.result def __str__(self): out = [ - f"transaction_hash={self.transaction_hash}", - f"result={self.result}", + f'transaction_hash={self.transaction_hash}', + f'result={self.result}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_result_result.py b/stellar_sdk/xdr/transaction_result_result.py index d42178cf..08c3ad4a 100644 --- a/stellar_sdk/xdr/transaction_result_result.py +++ b/stellar_sdk/xdr/transaction_result_result.py @@ -3,17 +3,16 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .transaction_result_code import TransactionResultCode from .inner_transaction_result_pair import InnerTransactionResultPair from .operation_result import OperationResult -from .transaction_result_code import TransactionResultCode - -__all__ = ["TransactionResultResult"] - - +__all__ = ['TransactionResultResult'] class TransactionResultResult: """ XDR Source Code:: @@ -45,7 +44,6 @@ class TransactionResultResult: void; } """ - def __init__( self, code: TransactionResultCode, @@ -54,13 +52,10 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if results and len(results) > _expect_max_length: - raise ValueError( - f"The maximum length of `results` should be {_expect_max_length}, but got {len(results)}." - ) + raise ValueError(f"The maximum length of `results` should be {_expect_max_length}, but got {len(results)}.") self.code = code self.inner_result_pair = inner_result_pair self.results = results - def pack(self, packer: Packer) -> None: self.code.pack(packer) if self.code == TransactionResultCode.txFEE_BUMP_INNER_SUCCESS: @@ -117,7 +112,6 @@ def pack(self, packer: Packer) -> None: return if self.code == TransactionResultCode.txSOROBAN_INVALID: return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionResultResult: code = TransactionResultCode.unpack(unpacker) @@ -170,7 +164,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionResultResult: if code == TransactionResultCode.txSOROBAN_INVALID: return cls(code=code) return cls(code=code) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -189,30 +182,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionResultResult: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.code, - self.inner_result_pair, - self.results, - ) - ) - + return hash((self.code, self.inner_result_pair, self.results,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.code == other.code - and self.inner_result_pair == other.inner_result_pair - and self.results == other.results - ) - + return self.code== other.code and self.inner_result_pair== other.inner_result_pair and self.results== other.results def __str__(self): out = [] - out.append(f"code={self.code}") - out.append( - f"inner_result_pair={self.inner_result_pair}" - ) if self.inner_result_pair is not None else None - out.append(f"results={self.results}") if self.results is not None else None + out.append(f'code={self.code}') + out.append(f'inner_result_pair={self.inner_result_pair}') if self.inner_result_pair is not None else None + out.append(f'results={self.results}') if self.results is not None else None return f"" diff --git a/stellar_sdk/xdr/transaction_result_set.py b/stellar_sdk/xdr/transaction_result_set.py index b769ea47..69b54933 100644 --- a/stellar_sdk/xdr/transaction_result_set.py +++ b/stellar_sdk/xdr/transaction_result_set.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .transaction_result_pair import TransactionResultPair - -__all__ = ["TransactionResultSet"] - - +__all__ = ['TransactionResultSet'] class TransactionResultSet: """ XDR Source Code:: @@ -21,23 +20,18 @@ class TransactionResultSet: TransactionResultPair results<>; }; """ - def __init__( self, results: List[TransactionResultPair], ) -> None: _expect_max_length = 4294967295 if results and len(results) > _expect_max_length: - raise ValueError( - f"The maximum length of `results` should be {_expect_max_length}, but got {len(results)}." - ) + raise ValueError(f"The maximum length of `results` should be {_expect_max_length}, but got {len(results)}.") self.results = results - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.results)) for results_item in self.results: results_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionResultSet: length = unpacker.unpack_uint() @@ -47,7 +41,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionResultSet: return cls( results=results, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -66,17 +59,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionResultSet: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.results,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.results == other.results - + return self.results== other.results def __str__(self): out = [ - f"results={self.results}", + f'results={self.results}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_set.py b/stellar_sdk/xdr/transaction_set.py index c1054da3..601b9320 100644 --- a/stellar_sdk/xdr/transaction_set.py +++ b/stellar_sdk/xdr/transaction_set.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash from .transaction_envelope import TransactionEnvelope - -__all__ = ["TransactionSet"] - - +__all__ = ['TransactionSet'] class TransactionSet: """ XDR Source Code:: @@ -23,7 +22,6 @@ class TransactionSet: TransactionEnvelope txs<>; }; """ - def __init__( self, previous_ledger_hash: Hash, @@ -31,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if txs and len(txs) > _expect_max_length: - raise ValueError( - f"The maximum length of `txs` should be {_expect_max_length}, but got {len(txs)}." - ) + raise ValueError(f"The maximum length of `txs` should be {_expect_max_length}, but got {len(txs)}.") self.previous_ledger_hash = previous_ledger_hash self.txs = txs - def pack(self, packer: Packer) -> None: self.previous_ledger_hash.pack(packer) packer.pack_uint(len(self.txs)) for txs_item in self.txs: txs_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionSet: previous_ledger_hash = Hash.unpack(unpacker) @@ -54,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionSet: previous_ledger_hash=previous_ledger_hash, txs=txs, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,26 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionSet: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.previous_ledger_hash, - self.txs, - ) - ) - + return hash((self.previous_ledger_hash, self.txs,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.previous_ledger_hash == other.previous_ledger_hash - and self.txs == other.txs - ) - + return self.previous_ledger_hash== other.previous_ledger_hash and self.txs== other.txs def __str__(self): out = [ - f"previous_ledger_hash={self.previous_ledger_hash}", - f"txs={self.txs}", + f'previous_ledger_hash={self.previous_ledger_hash}', + f'txs={self.txs}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_set_v1.py b/stellar_sdk/xdr/transaction_set_v1.py index 8666a95d..23aab0f0 100644 --- a/stellar_sdk/xdr/transaction_set_v1.py +++ b/stellar_sdk/xdr/transaction_set_v1.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash from .transaction_phase import TransactionPhase - -__all__ = ["TransactionSetV1"] - - +__all__ = ['TransactionSetV1'] class TransactionSetV1: """ XDR Source Code:: @@ -23,7 +22,6 @@ class TransactionSetV1: TransactionPhase phases<>; }; """ - def __init__( self, previous_ledger_hash: Hash, @@ -31,18 +29,14 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if phases and len(phases) > _expect_max_length: - raise ValueError( - f"The maximum length of `phases` should be {_expect_max_length}, but got {len(phases)}." - ) + raise ValueError(f"The maximum length of `phases` should be {_expect_max_length}, but got {len(phases)}.") self.previous_ledger_hash = previous_ledger_hash self.phases = phases - def pack(self, packer: Packer) -> None: self.previous_ledger_hash.pack(packer) packer.pack_uint(len(self.phases)) for phases_item in self.phases: phases_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionSetV1: previous_ledger_hash = Hash.unpack(unpacker) @@ -54,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionSetV1: previous_ledger_hash=previous_ledger_hash, phases=phases, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,26 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionSetV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.previous_ledger_hash, - self.phases, - ) - ) - + return hash((self.previous_ledger_hash, self.phases,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.previous_ledger_hash == other.previous_ledger_hash - and self.phases == other.phases - ) - + return self.previous_ledger_hash== other.previous_ledger_hash and self.phases== other.phases def __str__(self): out = [ - f"previous_ledger_hash={self.previous_ledger_hash}", - f"phases={self.phases}", + f'previous_ledger_hash={self.previous_ledger_hash}', + f'phases={self.phases}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_signature_payload.py b/stellar_sdk/xdr/transaction_signature_payload.py index c7e50605..3b3bd0b3 100644 --- a/stellar_sdk/xdr/transaction_signature_payload.py +++ b/stellar_sdk/xdr/transaction_signature_payload.py @@ -3,17 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .hash import Hash -from .transaction_signature_payload_tagged_transaction import ( - TransactionSignaturePayloadTaggedTransaction, -) - -__all__ = ["TransactionSignaturePayload"] - - +from .transaction_signature_payload_tagged_transaction import TransactionSignaturePayloadTaggedTransaction +__all__ = ['TransactionSignaturePayload'] class TransactionSignaturePayload: """ XDR Source Code:: @@ -32,7 +30,6 @@ class TransactionSignaturePayload: taggedTransaction; }; """ - def __init__( self, network_id: Hash, @@ -40,22 +37,17 @@ def __init__( ) -> None: self.network_id = network_id self.tagged_transaction = tagged_transaction - def pack(self, packer: Packer) -> None: self.network_id.pack(packer) self.tagged_transaction.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionSignaturePayload: network_id = Hash.unpack(unpacker) - tagged_transaction = TransactionSignaturePayloadTaggedTransaction.unpack( - unpacker - ) + tagged_transaction = TransactionSignaturePayloadTaggedTransaction.unpack(unpacker) return cls( network_id=network_id, tagged_transaction=tagged_transaction, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -74,26 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionSignaturePayload: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.network_id, - self.tagged_transaction, - ) - ) - + return hash((self.network_id, self.tagged_transaction,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.network_id == other.network_id - and self.tagged_transaction == other.tagged_transaction - ) - + return self.network_id== other.network_id and self.tagged_transaction== other.tagged_transaction def __str__(self): out = [ - f"network_id={self.network_id}", - f"tagged_transaction={self.tagged_transaction}", + f'network_id={self.network_id}', + f'tagged_transaction={self.tagged_transaction}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_signature_payload_tagged_transaction.py b/stellar_sdk/xdr/transaction_signature_payload_tagged_transaction.py index d6284cd3..e6282346 100644 --- a/stellar_sdk/xdr/transaction_signature_payload_tagged_transaction.py +++ b/stellar_sdk/xdr/transaction_signature_payload_tagged_transaction.py @@ -3,16 +3,16 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .envelope_type import EnvelopeType -from .fee_bump_transaction import FeeBumpTransaction from .transaction import Transaction - -__all__ = ["TransactionSignaturePayloadTaggedTransaction"] - - +from .fee_bump_transaction import FeeBumpTransaction +__all__ = ['TransactionSignaturePayloadTaggedTransaction'] class TransactionSignaturePayloadTaggedTransaction: """ XDR Source Code:: @@ -26,7 +26,6 @@ class TransactionSignaturePayloadTaggedTransaction: FeeBumpTransaction feeBump; } """ - def __init__( self, type: EnvelopeType, @@ -36,7 +35,6 @@ def __init__( self.type = type self.tx = tx self.fee_bump = fee_bump - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == EnvelopeType.ENVELOPE_TYPE_TX: @@ -49,7 +47,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("fee_bump should not be None.") self.fee_bump.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionSignaturePayloadTaggedTransaction: type = EnvelopeType.unpack(unpacker) @@ -60,7 +57,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionSignaturePayloadTaggedTransact fee_bump = FeeBumpTransaction.unpack(unpacker) return cls(type=type, fee_bump=fee_bump) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -79,28 +75,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionSignaturePayloadTaggedTransaction: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.tx, - self.fee_bump, - ) - ) - + return hash((self.type, self.tx, self.fee_bump,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.tx == other.tx - and self.fee_bump == other.fee_bump - ) - + return self.type== other.type and self.tx== other.tx and self.fee_bump== other.fee_bump def __str__(self): out = [] - out.append(f"type={self.type}") - out.append(f"tx={self.tx}") if self.tx is not None else None - out.append(f"fee_bump={self.fee_bump}") if self.fee_bump is not None else None + out.append(f'type={self.type}') + out.append(f'tx={self.tx}') if self.tx is not None else None + out.append(f'fee_bump={self.fee_bump}') if self.fee_bump is not None else None return f"" diff --git a/stellar_sdk/xdr/transaction_v0.py b/stellar_sdk/xdr/transaction_v0.py index 57ebb9a6..053b99b9 100644 --- a/stellar_sdk/xdr/transaction_v0.py +++ b/stellar_sdk/xdr/transaction_v0.py @@ -3,22 +3,20 @@ from __future__ import annotations import base64 -from typing import List, Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .memo import Memo -from .operation import Operation + +from .uint256 import Uint256 +from .uint32 import Uint32 from .sequence_number import SequenceNumber from .time_bounds import TimeBounds +from .memo import Memo +from .operation import Operation from .transaction_v0_ext import TransactionV0Ext -from .uint32 import Uint32 -from .uint256 import Uint256 - -__all__ = ["TransactionV0"] - - +__all__ = ['TransactionV0'] class TransactionV0: """ XDR Source Code:: @@ -39,7 +37,6 @@ class TransactionV0: ext; }; """ - def __init__( self, source_account_ed25519: Uint256, @@ -52,9 +49,7 @@ def __init__( ) -> None: _expect_max_length = MAX_OPS_PER_TX if operations and len(operations) > _expect_max_length: - raise ValueError( - f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}." - ) + raise ValueError(f"The maximum length of `operations` should be {_expect_max_length}, but got {len(operations)}.") self.source_account_ed25519 = source_account_ed25519 self.fee = fee self.seq_num = seq_num @@ -62,7 +57,6 @@ def __init__( self.memo = memo self.operations = operations self.ext = ext - def pack(self, packer: Packer) -> None: self.source_account_ed25519.pack(packer) self.fee.pack(packer) @@ -77,7 +71,6 @@ def pack(self, packer: Packer) -> None: for operations_item in self.operations: operations_item.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionV0: source_account_ed25519 = Uint256.unpack(unpacker) @@ -99,7 +92,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionV0: operations=operations, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -118,41 +110,20 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionV0: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.source_account_ed25519, - self.fee, - self.seq_num, - self.time_bounds, - self.memo, - self.operations, - self.ext, - ) - ) - + return hash((self.source_account_ed25519, self.fee, self.seq_num, self.time_bounds, self.memo, self.operations, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.source_account_ed25519 == other.source_account_ed25519 - and self.fee == other.fee - and self.seq_num == other.seq_num - and self.time_bounds == other.time_bounds - and self.memo == other.memo - and self.operations == other.operations - and self.ext == other.ext - ) - + return self.source_account_ed25519== other.source_account_ed25519 and self.fee== other.fee and self.seq_num== other.seq_num and self.time_bounds== other.time_bounds and self.memo== other.memo and self.operations== other.operations and self.ext== other.ext def __str__(self): out = [ - f"source_account_ed25519={self.source_account_ed25519}", - f"fee={self.fee}", - f"seq_num={self.seq_num}", - f"time_bounds={self.time_bounds}", - f"memo={self.memo}", - f"operations={self.operations}", - f"ext={self.ext}", + f'source_account_ed25519={self.source_account_ed25519}', + f'fee={self.fee}', + f'seq_num={self.seq_num}', + f'time_bounds={self.time_bounds}', + f'memo={self.memo}', + f'operations={self.operations}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_v0_envelope.py b/stellar_sdk/xdr/transaction_v0_envelope.py index 9440ac4d..8ad9e68d 100644 --- a/stellar_sdk/xdr/transaction_v0_envelope.py +++ b/stellar_sdk/xdr/transaction_v0_envelope.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .decorated_signature import DecoratedSignature from .transaction_v0 import TransactionV0 - -__all__ = ["TransactionV0Envelope"] - - +from .decorated_signature import DecoratedSignature +__all__ = ['TransactionV0Envelope'] class TransactionV0Envelope: """ XDR Source Code:: @@ -25,7 +24,6 @@ class TransactionV0Envelope: DecoratedSignature signatures<20>; }; """ - def __init__( self, tx: TransactionV0, @@ -33,18 +31,14 @@ def __init__( ) -> None: _expect_max_length = 20 if signatures and len(signatures) > _expect_max_length: - raise ValueError( - f"The maximum length of `signatures` should be {_expect_max_length}, but got {len(signatures)}." - ) + raise ValueError(f"The maximum length of `signatures` should be {_expect_max_length}, but got {len(signatures)}.") self.tx = tx self.signatures = signatures - def pack(self, packer: Packer) -> None: self.tx.pack(packer) packer.pack_uint(len(self.signatures)) for signatures_item in self.signatures: signatures_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionV0Envelope: tx = TransactionV0.unpack(unpacker) @@ -56,7 +50,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionV0Envelope: tx=tx, signatures=signatures, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -75,23 +68,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionV0Envelope: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.tx, - self.signatures, - ) - ) - + return hash((self.tx, self.signatures,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.tx == other.tx and self.signatures == other.signatures - + return self.tx== other.tx and self.signatures== other.signatures def __str__(self): out = [ - f"tx={self.tx}", - f"signatures={self.signatures}", + f'tx={self.tx}', + f'signatures={self.signatures}', ] return f"" diff --git a/stellar_sdk/xdr/transaction_v0_ext.py b/stellar_sdk/xdr/transaction_v0_ext.py index a6e7a436..efab8e8e 100644 --- a/stellar_sdk/xdr/transaction_v0_ext.py +++ b/stellar_sdk/xdr/transaction_v0_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["TransactionV0Ext"] - - +__all__ = ['TransactionV0Ext'] class TransactionV0Ext: """ XDR Source Code:: @@ -21,25 +20,21 @@ class TransactionV0Ext: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionV0Ext: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionV0Ext: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/transaction_v1_envelope.py b/stellar_sdk/xdr/transaction_v1_envelope.py index a10ca877..66a8e060 100644 --- a/stellar_sdk/xdr/transaction_v1_envelope.py +++ b/stellar_sdk/xdr/transaction_v1_envelope.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .decorated_signature import DecoratedSignature from .transaction import Transaction - -__all__ = ["TransactionV1Envelope"] - - +from .decorated_signature import DecoratedSignature +__all__ = ['TransactionV1Envelope'] class TransactionV1Envelope: """ XDR Source Code:: @@ -25,7 +24,6 @@ class TransactionV1Envelope: DecoratedSignature signatures<20>; }; """ - def __init__( self, tx: Transaction, @@ -33,18 +31,14 @@ def __init__( ) -> None: _expect_max_length = 20 if signatures and len(signatures) > _expect_max_length: - raise ValueError( - f"The maximum length of `signatures` should be {_expect_max_length}, but got {len(signatures)}." - ) + raise ValueError(f"The maximum length of `signatures` should be {_expect_max_length}, but got {len(signatures)}.") self.tx = tx self.signatures = signatures - def pack(self, packer: Packer) -> None: self.tx.pack(packer) packer.pack_uint(len(self.signatures)) for signatures_item in self.signatures: signatures_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TransactionV1Envelope: tx = Transaction.unpack(unpacker) @@ -56,7 +50,6 @@ def unpack(cls, unpacker: Unpacker) -> TransactionV1Envelope: tx=tx, signatures=signatures, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -75,23 +68,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TransactionV1Envelope: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.tx, - self.signatures, - ) - ) - + return hash((self.tx, self.signatures,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.tx == other.tx and self.signatures == other.signatures - + return self.tx== other.tx and self.signatures== other.signatures def __str__(self): out = [ - f"tx={self.tx}", - f"signatures={self.signatures}", + f'tx={self.tx}', + f'signatures={self.signatures}', ] return f"" diff --git a/stellar_sdk/xdr/trust_line_asset.py b/stellar_sdk/xdr/trust_line_asset.py index a41e7d12..ae0d8aa4 100644 --- a/stellar_sdk/xdr/trust_line_asset.py +++ b/stellar_sdk/xdr/trust_line_asset.py @@ -3,17 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * +from .asset_type import AssetType from .alpha_num4 import AlphaNum4 from .alpha_num12 import AlphaNum12 -from .asset_type import AssetType from .pool_id import PoolID - -__all__ = ["TrustLineAsset"] - - +__all__ = ['TrustLineAsset'] class TrustLineAsset: """ XDR Source Code:: @@ -35,7 +35,6 @@ class TrustLineAsset: // add other asset types here in the future }; """ - def __init__( self, type: AssetType, @@ -47,7 +46,6 @@ def __init__( self.alpha_num4 = alpha_num4 self.alpha_num12 = alpha_num12 self.liquidity_pool_id = liquidity_pool_id - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == AssetType.ASSET_TYPE_NATIVE: @@ -67,7 +65,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("liquidity_pool_id should not be None.") self.liquidity_pool_id.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TrustLineAsset: type = AssetType.unpack(unpacker) @@ -83,7 +80,6 @@ def unpack(cls, unpacker: Unpacker) -> TrustLineAsset: liquidity_pool_id = PoolID.unpack(unpacker) return cls(type=type, liquidity_pool_id=liquidity_pool_id) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -102,37 +98,16 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TrustLineAsset: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.alpha_num4, - self.alpha_num12, - self.liquidity_pool_id, - ) - ) - + return hash((self.type, self.alpha_num4, self.alpha_num12, self.liquidity_pool_id,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.alpha_num4 == other.alpha_num4 - and self.alpha_num12 == other.alpha_num12 - and self.liquidity_pool_id == other.liquidity_pool_id - ) - + return self.type== other.type and self.alpha_num4== other.alpha_num4 and self.alpha_num12== other.alpha_num12 and self.liquidity_pool_id== other.liquidity_pool_id def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"alpha_num4={self.alpha_num4}" - ) if self.alpha_num4 is not None else None - out.append( - f"alpha_num12={self.alpha_num12}" - ) if self.alpha_num12 is not None else None - out.append( - f"liquidity_pool_id={self.liquidity_pool_id}" - ) if self.liquidity_pool_id is not None else None + out.append(f'type={self.type}') + out.append(f'alpha_num4={self.alpha_num4}') if self.alpha_num4 is not None else None + out.append(f'alpha_num12={self.alpha_num12}') if self.alpha_num12 is not None else None + out.append(f'liquidity_pool_id={self.liquidity_pool_id}') if self.liquidity_pool_id is not None else None return f"" diff --git a/stellar_sdk/xdr/trust_line_entry.py b/stellar_sdk/xdr/trust_line_entry.py index ffa7c021..bd983e4d 100644 --- a/stellar_sdk/xdr/trust_line_entry.py +++ b/stellar_sdk/xdr/trust_line_entry.py @@ -3,18 +3,19 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .account_id import AccountID -from .int64 import Int64 from .trust_line_asset import TrustLineAsset -from .trust_line_entry_ext import TrustLineEntryExt +from .int64 import Int64 +from .int64 import Int64 from .uint32 import Uint32 - -__all__ = ["TrustLineEntry"] - - +from .trust_line_entry_ext import TrustLineEntryExt +__all__ = ['TrustLineEntry'] class TrustLineEntry: """ XDR Source Code:: @@ -52,7 +53,6 @@ class TrustLineEntry: ext; }; """ - def __init__( self, account_id: AccountID, @@ -68,7 +68,6 @@ def __init__( self.limit = limit self.flags = flags self.ext = ext - def pack(self, packer: Packer) -> None: self.account_id.pack(packer) self.asset.pack(packer) @@ -76,7 +75,6 @@ def pack(self, packer: Packer) -> None: self.limit.pack(packer) self.flags.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TrustLineEntry: account_id = AccountID.unpack(unpacker) @@ -93,7 +91,6 @@ def unpack(cls, unpacker: Unpacker) -> TrustLineEntry: flags=flags, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -112,38 +109,19 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TrustLineEntry: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.account_id, - self.asset, - self.balance, - self.limit, - self.flags, - self.ext, - ) - ) - + return hash((self.account_id, self.asset, self.balance, self.limit, self.flags, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.account_id == other.account_id - and self.asset == other.asset - and self.balance == other.balance - and self.limit == other.limit - and self.flags == other.flags - and self.ext == other.ext - ) - + return self.account_id== other.account_id and self.asset== other.asset and self.balance== other.balance and self.limit== other.limit and self.flags== other.flags and self.ext== other.ext def __str__(self): out = [ - f"account_id={self.account_id}", - f"asset={self.asset}", - f"balance={self.balance}", - f"limit={self.limit}", - f"flags={self.flags}", - f"ext={self.ext}", + f'account_id={self.account_id}', + f'asset={self.asset}', + f'balance={self.balance}', + f'limit={self.limit}', + f'flags={self.flags}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/trust_line_entry_ext.py b/stellar_sdk/xdr/trust_line_entry_ext.py index 36e8fb7d..412b9d76 100644 --- a/stellar_sdk/xdr/trust_line_entry_ext.py +++ b/stellar_sdk/xdr/trust_line_entry_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .trust_line_entry_v1 import TrustLineEntryV1 - -__all__ = ["TrustLineEntryExt"] - - +__all__ = ['TrustLineEntryExt'] class TrustLineEntryExt: """ XDR Source Code:: @@ -36,7 +35,6 @@ class TrustLineEntryExt: } v1; } """ - def __init__( self, v: int, @@ -44,7 +42,6 @@ def __init__( ) -> None: self.v = v self.v1 = v1 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -54,7 +51,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v1 should not be None.") self.v1.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TrustLineEntryExt: v = Integer.unpack(unpacker) @@ -64,7 +60,6 @@ def unpack(cls, unpacker: Unpacker) -> TrustLineEntryExt: v1 = TrustLineEntryV1.unpack(unpacker) return cls(v=v, v1=v1) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -83,22 +78,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TrustLineEntryExt: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v1, - ) - ) - + return hash((self.v, self.v1,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v1 == other.v1 - + return self.v== other.v and self.v1== other.v1 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v1={self.v1}") if self.v1 is not None else None + out.append(f'v={self.v}') + out.append(f'v1={self.v1}') if self.v1 is not None else None return f"" diff --git a/stellar_sdk/xdr/trust_line_entry_extension_v2.py b/stellar_sdk/xdr/trust_line_entry_extension_v2.py index 55744e0d..501b7764 100644 --- a/stellar_sdk/xdr/trust_line_entry_extension_v2.py +++ b/stellar_sdk/xdr/trust_line_entry_extension_v2.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int32 import Int32 from .trust_line_entry_extension_v2_ext import TrustLineEntryExtensionV2Ext - -__all__ = ["TrustLineEntryExtensionV2"] - - +__all__ = ['TrustLineEntryExtensionV2'] class TrustLineEntryExtensionV2: """ XDR Source Code:: @@ -28,7 +28,6 @@ class TrustLineEntryExtensionV2: ext; }; """ - def __init__( self, liquidity_pool_use_count: Int32, @@ -36,11 +35,9 @@ def __init__( ) -> None: self.liquidity_pool_use_count = liquidity_pool_use_count self.ext = ext - def pack(self, packer: Packer) -> None: self.liquidity_pool_use_count.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TrustLineEntryExtensionV2: liquidity_pool_use_count = Int32.unpack(unpacker) @@ -49,7 +46,6 @@ def unpack(cls, unpacker: Unpacker) -> TrustLineEntryExtensionV2: liquidity_pool_use_count=liquidity_pool_use_count, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -68,26 +64,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TrustLineEntryExtensionV2: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.liquidity_pool_use_count, - self.ext, - ) - ) - + return hash((self.liquidity_pool_use_count, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.liquidity_pool_use_count == other.liquidity_pool_use_count - and self.ext == other.ext - ) - + return self.liquidity_pool_use_count== other.liquidity_pool_use_count and self.ext== other.ext def __str__(self): out = [ - f"liquidity_pool_use_count={self.liquidity_pool_use_count}", - f"ext={self.ext}", + f'liquidity_pool_use_count={self.liquidity_pool_use_count}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/trust_line_entry_extension_v2_ext.py b/stellar_sdk/xdr/trust_line_entry_extension_v2_ext.py index ab001c1b..580be183 100644 --- a/stellar_sdk/xdr/trust_line_entry_extension_v2_ext.py +++ b/stellar_sdk/xdr/trust_line_entry_extension_v2_ext.py @@ -3,14 +3,13 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer - -__all__ = ["TrustLineEntryExtensionV2Ext"] - - +__all__ = ['TrustLineEntryExtensionV2Ext'] class TrustLineEntryExtensionV2Ext: """ XDR Source Code:: @@ -21,25 +20,21 @@ class TrustLineEntryExtensionV2Ext: void; } """ - def __init__( self, v: int, ) -> None: self.v = v - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: return - @classmethod def unpack(cls, unpacker: Unpacker) -> TrustLineEntryExtensionV2Ext: v = Integer.unpack(unpacker) if v == 0: return cls(v=v) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -58,16 +53,13 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TrustLineEntryExtensionV2Ext: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash((self.v,)) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v - + return self.v== other.v def __str__(self): out = [] - out.append(f"v={self.v}") + out.append(f'v={self.v}') return f"" diff --git a/stellar_sdk/xdr/trust_line_entry_v1.py b/stellar_sdk/xdr/trust_line_entry_v1.py index 8f323a62..2fe7179a 100644 --- a/stellar_sdk/xdr/trust_line_entry_v1.py +++ b/stellar_sdk/xdr/trust_line_entry_v1.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .liabilities import Liabilities from .trust_line_entry_v1_ext import TrustLineEntryV1Ext - -__all__ = ["TrustLineEntryV1"] - - +__all__ = ['TrustLineEntryV1'] class TrustLineEntryV1: """ XDR Source Code:: @@ -30,7 +30,6 @@ class TrustLineEntryV1: ext; } """ - def __init__( self, liabilities: Liabilities, @@ -38,11 +37,9 @@ def __init__( ) -> None: self.liabilities = liabilities self.ext = ext - def pack(self, packer: Packer) -> None: self.liabilities.pack(packer) self.ext.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TrustLineEntryV1: liabilities = Liabilities.unpack(unpacker) @@ -51,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> TrustLineEntryV1: liabilities=liabilities, ext=ext, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -70,23 +66,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TrustLineEntryV1: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.liabilities, - self.ext, - ) - ) - + return hash((self.liabilities, self.ext,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.liabilities == other.liabilities and self.ext == other.ext - + return self.liabilities== other.liabilities and self.ext== other.ext def __str__(self): out = [ - f"liabilities={self.liabilities}", - f"ext={self.ext}", + f'liabilities={self.liabilities}', + f'ext={self.ext}', ] return f"" diff --git a/stellar_sdk/xdr/trust_line_entry_v1_ext.py b/stellar_sdk/xdr/trust_line_entry_v1_ext.py index 932cb24f..0802ba80 100644 --- a/stellar_sdk/xdr/trust_line_entry_v1_ext.py +++ b/stellar_sdk/xdr/trust_line_entry_v1_ext.py @@ -3,15 +3,14 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Integer from .trust_line_entry_extension_v2 import TrustLineEntryExtensionV2 - -__all__ = ["TrustLineEntryV1Ext"] - - +__all__ = ['TrustLineEntryV1Ext'] class TrustLineEntryV1Ext: """ XDR Source Code:: @@ -24,7 +23,6 @@ class TrustLineEntryV1Ext: TrustLineEntryExtensionV2 v2; } """ - def __init__( self, v: int, @@ -32,7 +30,6 @@ def __init__( ) -> None: self.v = v self.v2 = v2 - def pack(self, packer: Packer) -> None: Integer(self.v).pack(packer) if self.v == 0: @@ -42,7 +39,6 @@ def pack(self, packer: Packer) -> None: raise ValueError("v2 should not be None.") self.v2.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TrustLineEntryV1Ext: v = Integer.unpack(unpacker) @@ -52,7 +48,6 @@ def unpack(cls, unpacker: Unpacker) -> TrustLineEntryV1Ext: v2 = TrustLineEntryExtensionV2.unpack(unpacker) return cls(v=v, v2=v2) return cls(v=v) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -71,22 +66,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TrustLineEntryV1Ext: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.v, - self.v2, - ) - ) - + return hash((self.v, self.v2,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.v == other.v and self.v2 == other.v2 - + return self.v== other.v and self.v2== other.v2 def __str__(self): out = [] - out.append(f"v={self.v}") - out.append(f"v2={self.v2}") if self.v2 is not None else None + out.append(f'v={self.v}') + out.append(f'v2={self.v2}') if self.v2 is not None else None return f"" diff --git a/stellar_sdk/xdr/trust_line_flags.py b/stellar_sdk/xdr/trust_line_flags.py index 98afb8b7..bb871281 100644 --- a/stellar_sdk/xdr/trust_line_flags.py +++ b/stellar_sdk/xdr/trust_line_flags.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["TrustLineFlags"] - - +__all__ = ['TrustLineFlags'] class TrustLineFlags(IntEnum): """ XDR Source Code:: @@ -26,11 +26,9 @@ class TrustLineFlags(IntEnum): TRUSTLINE_CLAWBACK_ENABLED_FLAG = 4 }; """ - AUTHORIZED_FLAG = 1 AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG = 2 TRUSTLINE_CLAWBACK_ENABLED_FLAG = 4 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -38,7 +36,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> TrustLineFlags: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/tx_advert_vector.py b/stellar_sdk/xdr/tx_advert_vector.py index ed1dec38..70086340 100644 --- a/stellar_sdk/xdr/tx_advert_vector.py +++ b/stellar_sdk/xdr/tx_advert_vector.py @@ -3,36 +3,29 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .hash import Hash - -__all__ = ["TxAdvertVector"] - +from .hash import Hash +__all__ = ['TxAdvertVector'] class TxAdvertVector: """ XDR Source Code:: typedef Hash TxAdvertVector; """ - def __init__(self, tx_advert_vector: List[Hash]) -> None: _expect_max_length = TX_ADVERT_VECTOR_MAX_SIZE if tx_advert_vector and len(tx_advert_vector) > _expect_max_length: - raise ValueError( - f"The maximum length of `tx_advert_vector` should be {_expect_max_length}, but got {len(tx_advert_vector)}." - ) + raise ValueError(f"The maximum length of `tx_advert_vector` should be {_expect_max_length}, but got {len(tx_advert_vector)}.") self.tx_advert_vector = tx_advert_vector - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.tx_advert_vector)) for tx_advert_vector_item in self.tx_advert_vector: tx_advert_vector_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TxAdvertVector: length = unpacker.unpack_uint() @@ -40,7 +33,6 @@ def unpack(cls, unpacker: Unpacker) -> TxAdvertVector: for _ in range(length): tx_advert_vector.append(Hash.unpack(unpacker)) return cls(tx_advert_vector) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -59,10 +51,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TxAdvertVector: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.tx_advert_vector) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/tx_demand_vector.py b/stellar_sdk/xdr/tx_demand_vector.py index 07c662fe..b31bdd87 100644 --- a/stellar_sdk/xdr/tx_demand_vector.py +++ b/stellar_sdk/xdr/tx_demand_vector.py @@ -3,36 +3,29 @@ from __future__ import annotations import base64 -from typing import List - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker - +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque from .constants import * -from .hash import Hash - -__all__ = ["TxDemandVector"] - +from .hash import Hash +__all__ = ['TxDemandVector'] class TxDemandVector: """ XDR Source Code:: typedef Hash TxDemandVector; """ - def __init__(self, tx_demand_vector: List[Hash]) -> None: _expect_max_length = TX_DEMAND_VECTOR_MAX_SIZE if tx_demand_vector and len(tx_demand_vector) > _expect_max_length: - raise ValueError( - f"The maximum length of `tx_demand_vector` should be {_expect_max_length}, but got {len(tx_demand_vector)}." - ) + raise ValueError(f"The maximum length of `tx_demand_vector` should be {_expect_max_length}, but got {len(tx_demand_vector)}.") self.tx_demand_vector = tx_demand_vector - def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.tx_demand_vector)) for tx_demand_vector_item in self.tx_demand_vector: tx_demand_vector_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TxDemandVector: length = unpacker.unpack_uint() @@ -40,7 +33,6 @@ def unpack(cls, unpacker: Unpacker) -> TxDemandVector: for _ in range(length): tx_demand_vector.append(Hash.unpack(unpacker)) return cls(tx_demand_vector) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -59,10 +51,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TxDemandVector: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.tx_demand_vector) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/tx_set_component.py b/stellar_sdk/xdr/tx_set_component.py index d8662401..a033f86f 100644 --- a/stellar_sdk/xdr/tx_set_component.py +++ b/stellar_sdk/xdr/tx_set_component.py @@ -3,17 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .tx_set_component_txs_maybe_discounted_fee import ( - TxSetComponentTxsMaybeDiscountedFee, -) from .tx_set_component_type import TxSetComponentType - -__all__ = ["TxSetComponent"] - - +from .tx_set_component_txs_maybe_discounted_fee import TxSetComponentTxsMaybeDiscountedFee +__all__ = ['TxSetComponent'] class TxSetComponent: """ XDR Source Code:: @@ -28,7 +26,6 @@ class TxSetComponent: } txsMaybeDiscountedFee; }; """ - def __init__( self, type: TxSetComponentType, @@ -36,7 +33,6 @@ def __init__( ) -> None: self.type = type self.txs_maybe_discounted_fee = txs_maybe_discounted_fee - def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == TxSetComponentType.TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: @@ -44,17 +40,13 @@ def pack(self, packer: Packer) -> None: raise ValueError("txs_maybe_discounted_fee should not be None.") self.txs_maybe_discounted_fee.pack(packer) return - @classmethod def unpack(cls, unpacker: Unpacker) -> TxSetComponent: type = TxSetComponentType.unpack(unpacker) if type == TxSetComponentType.TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: - txs_maybe_discounted_fee = TxSetComponentTxsMaybeDiscountedFee.unpack( - unpacker - ) + txs_maybe_discounted_fee = TxSetComponentTxsMaybeDiscountedFee.unpack(unpacker) return cls(type=type, txs_maybe_discounted_fee=txs_maybe_discounted_fee) return cls(type=type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -73,27 +65,14 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TxSetComponent: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.type, - self.txs_maybe_discounted_fee, - ) - ) - + return hash((self.type, self.txs_maybe_discounted_fee,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.type == other.type - and self.txs_maybe_discounted_fee == other.txs_maybe_discounted_fee - ) - + return self.type== other.type and self.txs_maybe_discounted_fee== other.txs_maybe_discounted_fee def __str__(self): out = [] - out.append(f"type={self.type}") - out.append( - f"txs_maybe_discounted_fee={self.txs_maybe_discounted_fee}" - ) if self.txs_maybe_discounted_fee is not None else None + out.append(f'type={self.type}') + out.append(f'txs_maybe_discounted_fee={self.txs_maybe_discounted_fee}') if self.txs_maybe_discounted_fee is not None else None return f"" diff --git a/stellar_sdk/xdr/tx_set_component_txs_maybe_discounted_fee.py b/stellar_sdk/xdr/tx_set_component_txs_maybe_discounted_fee.py index def82b77..8c48eb13 100644 --- a/stellar_sdk/xdr/tx_set_component_txs_maybe_discounted_fee.py +++ b/stellar_sdk/xdr/tx_set_component_txs_maybe_discounted_fee.py @@ -3,16 +3,15 @@ from __future__ import annotations import base64 -from typing import List, Optional - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .int64 import Int64 from .transaction_envelope import TransactionEnvelope - -__all__ = ["TxSetComponentTxsMaybeDiscountedFee"] - - +__all__ = ['TxSetComponentTxsMaybeDiscountedFee'] class TxSetComponentTxsMaybeDiscountedFee: """ XDR Source Code:: @@ -23,7 +22,6 @@ class TxSetComponentTxsMaybeDiscountedFee: TransactionEnvelope txs<>; } """ - def __init__( self, base_fee: Optional[Int64], @@ -31,12 +29,9 @@ def __init__( ) -> None: _expect_max_length = 4294967295 if txs and len(txs) > _expect_max_length: - raise ValueError( - f"The maximum length of `txs` should be {_expect_max_length}, but got {len(txs)}." - ) + raise ValueError(f"The maximum length of `txs` should be {_expect_max_length}, but got {len(txs)}.") self.base_fee = base_fee self.txs = txs - def pack(self, packer: Packer) -> None: if self.base_fee is None: packer.pack_uint(0) @@ -46,7 +41,6 @@ def pack(self, packer: Packer) -> None: packer.pack_uint(len(self.txs)) for txs_item in self.txs: txs_item.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> TxSetComponentTxsMaybeDiscountedFee: base_fee = Int64.unpack(unpacker) if unpacker.unpack_uint() else None @@ -58,7 +52,6 @@ def unpack(cls, unpacker: Unpacker) -> TxSetComponentTxsMaybeDiscountedFee: base_fee=base_fee, txs=txs, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -77,23 +70,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> TxSetComponentTxsMaybeDiscountedFee: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.base_fee, - self.txs, - ) - ) - + return hash((self.base_fee, self.txs,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.base_fee == other.base_fee and self.txs == other.txs - + return self.base_fee== other.base_fee and self.txs== other.txs def __str__(self): out = [ - f"base_fee={self.base_fee}", - f"txs={self.txs}", + f'base_fee={self.base_fee}', + f'txs={self.txs}', ] return f"" diff --git a/stellar_sdk/xdr/tx_set_component_type.py b/stellar_sdk/xdr/tx_set_component_type.py index ac3d6bcc..07e90d8f 100644 --- a/stellar_sdk/xdr/tx_set_component_type.py +++ b/stellar_sdk/xdr/tx_set_component_type.py @@ -4,12 +4,12 @@ import base64 from enum import IntEnum - +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -__all__ = ["TxSetComponentType"] - - +__all__ = ['TxSetComponentType'] class TxSetComponentType(IntEnum): """ XDR Source Code:: @@ -21,9 +21,7 @@ class TxSetComponentType(IntEnum): TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE = 0 }; """ - TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE = 0 - def pack(self, packer: Packer) -> None: packer.pack_int(self.value) @@ -31,7 +29,6 @@ def pack(self, packer: Packer) -> None: def unpack(cls, unpacker: Unpacker) -> TxSetComponentType: value = unpacker.unpack_int() return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) diff --git a/stellar_sdk/xdr/u_int128_parts.py b/stellar_sdk/xdr/u_int128_parts.py index 44def556..b7721cbe 100644 --- a/stellar_sdk/xdr/u_int128_parts.py +++ b/stellar_sdk/xdr/u_int128_parts.py @@ -3,14 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint64 import Uint64 - -__all__ = ["UInt128Parts"] - - +from .uint64 import Uint64 +__all__ = ['UInt128Parts'] class UInt128Parts: """ XDR Source Code:: @@ -20,7 +21,6 @@ class UInt128Parts: uint64 lo; }; """ - def __init__( self, hi: Uint64, @@ -28,11 +28,9 @@ def __init__( ) -> None: self.hi = hi self.lo = lo - def pack(self, packer: Packer) -> None: self.hi.pack(packer) self.lo.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> UInt128Parts: hi = Uint64.unpack(unpacker) @@ -41,7 +39,6 @@ def unpack(cls, unpacker: Unpacker) -> UInt128Parts: hi=hi, lo=lo, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -60,23 +57,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> UInt128Parts: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.hi, - self.lo, - ) - ) - + return hash((self.hi, self.lo,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.hi == other.hi and self.lo == other.lo - + return self.hi== other.hi and self.lo== other.lo def __str__(self): out = [ - f"hi={self.hi}", - f"lo={self.lo}", + f'hi={self.hi}', + f'lo={self.lo}', ] return f"" diff --git a/stellar_sdk/xdr/u_int256_parts.py b/stellar_sdk/xdr/u_int256_parts.py index 1a86c5a6..81cf12c1 100644 --- a/stellar_sdk/xdr/u_int256_parts.py +++ b/stellar_sdk/xdr/u_int256_parts.py @@ -3,14 +3,17 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * from .uint64 import Uint64 - -__all__ = ["UInt256Parts"] - - +from .uint64 import Uint64 +from .uint64 import Uint64 +from .uint64 import Uint64 +__all__ = ['UInt256Parts'] class UInt256Parts: """ XDR Source Code:: @@ -22,7 +25,6 @@ class UInt256Parts: uint64 lo_lo; }; """ - def __init__( self, hi_hi: Uint64, @@ -34,13 +36,11 @@ def __init__( self.hi_lo = hi_lo self.lo_hi = lo_hi self.lo_lo = lo_lo - def pack(self, packer: Packer) -> None: self.hi_hi.pack(packer) self.hi_lo.pack(packer) self.lo_hi.pack(packer) self.lo_lo.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> UInt256Parts: hi_hi = Uint64.unpack(unpacker) @@ -53,7 +53,6 @@ def unpack(cls, unpacker: Unpacker) -> UInt256Parts: lo_hi=lo_hi, lo_lo=lo_lo, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -72,32 +71,17 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> UInt256Parts: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.hi_hi, - self.hi_lo, - self.lo_hi, - self.lo_lo, - ) - ) - + return hash((self.hi_hi, self.hi_lo, self.lo_hi, self.lo_lo,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return ( - self.hi_hi == other.hi_hi - and self.hi_lo == other.hi_lo - and self.lo_hi == other.lo_hi - and self.lo_lo == other.lo_lo - ) - + return self.hi_hi== other.hi_hi and self.hi_lo== other.hi_lo and self.lo_hi== other.lo_hi and self.lo_lo== other.lo_lo def __str__(self): out = [ - f"hi_hi={self.hi_hi}", - f"hi_lo={self.hi_lo}", - f"lo_hi={self.lo_hi}", - f"lo_lo={self.lo_lo}", + f'hi_hi={self.hi_hi}', + f'hi_lo={self.hi_lo}', + f'lo_hi={self.lo_hi}', + f'lo_lo={self.lo_lo}', ] return f"" diff --git a/stellar_sdk/xdr/uint256.py b/stellar_sdk/xdr/uint256.py index 759b14c9..825d13db 100644 --- a/stellar_sdk/xdr/uint256.py +++ b/stellar_sdk/xdr/uint256.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["Uint256"] - - +__all__ = ['Uint256'] class Uint256: """ XDR Source Code:: typedef opaque uint256[32]; """ - def __init__(self, uint256: bytes) -> None: self.uint256 = uint256 - def pack(self, packer: Packer) -> None: Opaque(self.uint256, 32, True).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Uint256: uint256 = Opaque.unpack(unpacker, 32, True) return cls(uint256) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Uint256: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.uint256) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/uint32.py b/stellar_sdk/xdr/uint32.py index 4b9c0ee2..d1239e33 100644 --- a/stellar_sdk/xdr/uint32.py +++ b/stellar_sdk/xdr/uint32.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import UnsignedInteger - -__all__ = ["Uint32"] - - +__all__ = ['Uint32'] class Uint32: """ XDR Source Code:: typedef unsigned int uint32; """ - def __init__(self, uint32: int) -> None: self.uint32 = uint32 - def pack(self, packer: Packer) -> None: UnsignedInteger(self.uint32).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Uint32: uint32 = UnsignedInteger.unpack(unpacker) return cls(uint32) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Uint32: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.uint32) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/uint64.py b/stellar_sdk/xdr/uint64.py index ec2fc3d3..52ad7d72 100644 --- a/stellar_sdk/xdr/uint64.py +++ b/stellar_sdk/xdr/uint64.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import UnsignedHyper - -__all__ = ["Uint64"] - - +__all__ = ['Uint64'] class Uint64: """ XDR Source Code:: typedef unsigned hyper uint64; """ - def __init__(self, uint64: int) -> None: self.uint64 = uint64 - def pack(self, packer: Packer) -> None: UnsignedHyper(self.uint64).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Uint64: uint64 = UnsignedHyper.unpack(unpacker) return cls(uint64) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Uint64: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.uint64) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/upgrade_entry_meta.py b/stellar_sdk/xdr/upgrade_entry_meta.py index 7db02728..d159a5eb 100644 --- a/stellar_sdk/xdr/upgrade_entry_meta.py +++ b/stellar_sdk/xdr/upgrade_entry_meta.py @@ -3,15 +3,15 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .ledger_entry_changes import LedgerEntryChanges from .ledger_upgrade import LedgerUpgrade - -__all__ = ["UpgradeEntryMeta"] - - +from .ledger_entry_changes import LedgerEntryChanges +__all__ = ['UpgradeEntryMeta'] class UpgradeEntryMeta: """ XDR Source Code:: @@ -22,7 +22,6 @@ class UpgradeEntryMeta: LedgerEntryChanges changes; }; """ - def __init__( self, upgrade: LedgerUpgrade, @@ -30,11 +29,9 @@ def __init__( ) -> None: self.upgrade = upgrade self.changes = changes - def pack(self, packer: Packer) -> None: self.upgrade.pack(packer) self.changes.pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> UpgradeEntryMeta: upgrade = LedgerUpgrade.unpack(unpacker) @@ -43,7 +40,6 @@ def unpack(cls, unpacker: Unpacker) -> UpgradeEntryMeta: upgrade=upgrade, changes=changes, ) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -62,23 +58,15 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> UpgradeEntryMeta: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): - return hash( - ( - self.upgrade, - self.changes, - ) - ) - + return hash((self.upgrade, self.changes,)) def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented - return self.upgrade == other.upgrade and self.changes == other.changes - + return self.upgrade== other.upgrade and self.changes== other.changes def __str__(self): out = [ - f"upgrade={self.upgrade}", - f"changes={self.changes}", + f'upgrade={self.upgrade}', + f'changes={self.changes}', ] return f"" diff --git a/stellar_sdk/xdr/upgrade_type.py b/stellar_sdk/xdr/upgrade_type.py index 4574e8e8..6832b010 100644 --- a/stellar_sdk/xdr/upgrade_type.py +++ b/stellar_sdk/xdr/upgrade_type.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["UpgradeType"] - - +__all__ = ['UpgradeType'] class UpgradeType: """ XDR Source Code:: typedef opaque UpgradeType<128>; """ - def __init__(self, upgrade_type: bytes) -> None: self.upgrade_type = upgrade_type - def pack(self, packer: Packer) -> None: Opaque(self.upgrade_type, 128, False).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> UpgradeType: upgrade_type = Opaque.unpack(unpacker, 128, False) return cls(upgrade_type) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> UpgradeType: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.upgrade_type) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented diff --git a/stellar_sdk/xdr/value.py b/stellar_sdk/xdr/value.py index 890df944..91a29c4d 100644 --- a/stellar_sdk/xdr/value.py +++ b/stellar_sdk/xdr/value.py @@ -3,32 +3,27 @@ from __future__ import annotations import base64 - +from enum import IntEnum +from typing import List, Optional, TYPE_CHECKING from xdrlib3 import Packer, Unpacker +from .base import Integer, UnsignedInteger, Float, Double, Hyper, UnsignedHyper, Boolean, String, Opaque +from .constants import * -from .base import Opaque - -__all__ = ["Value"] - - +__all__ = ['Value'] class Value: """ XDR Source Code:: typedef opaque Value<>; """ - def __init__(self, value: bytes) -> None: self.value = value - def pack(self, packer: Packer) -> None: Opaque(self.value, 4294967295, False).pack(packer) - @classmethod def unpack(cls, unpacker: Unpacker) -> Value: value = Opaque.unpack(unpacker, 4294967295, False) return cls(value) - def to_xdr_bytes(self) -> bytes: packer = Packer() self.pack(packer) @@ -47,10 +42,8 @@ def to_xdr(self) -> str: def from_xdr(cls, xdr: str) -> Value: xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes) - def __hash__(self): return hash(self.value) - def __eq__(self, other: object): if not isinstance(other, self.__class__): return NotImplemented