From 8e5e13d10e17225dd7bd8c1b85a6bbc43b33708c Mon Sep 17 00:00:00 2001 From: Yahav Amar Date: Wed, 1 Nov 2023 17:47:35 +0200 Subject: [PATCH] mr comments implemented - move comments under function definitions --- fireblocks_sdk/sdk.py | 322 +++++++++++++++++++++--------------------- 1 file changed, 161 insertions(+), 161 deletions(-) diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index 4b4260c..09a78eb 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -67,13 +67,13 @@ def handle_response(response, page_mode=False): class FireblocksSDK(object): def __init__( - self, - private_key, - api_key, - api_base_url="https://api.fireblocks.io", - timeout=None, - anonymous_platform=False, - seconds_jwt_exp=55, + self, + private_key, + api_key, + api_base_url="https://api.fireblocks.io", + timeout=None, + anonymous_platform=False, + seconds_jwt_exp=55, ): """Creates a new Fireblocks API Client. @@ -113,38 +113,38 @@ def link_token(self, asset_id: str): def unlink_token(self, asset_id: str): return self._delete_request(f"/v1/tokenization/tokens/{asset_id}") - """Get all staking chains.""" def get_staking_chains(self): + """Get all staking chains.""" return self._get_request(f"/v1/staking/chains") - """Get chain info.""" def get_staking_chain_info(self, chain_descriptor: str): + """Get chain info.""" return self._get_request(f"/v1/staking/chains/{chain_descriptor}/chainInfo") - """Get staking positions summary.""" def get_staking_positions_summary(self, by_vault: bool = None): + """Get staking positions summary.""" return self._get_request(f"/v1/staking/positions/summary", query_params={"byVault": "true"} if by_vault else None) - """Execute staking action on a chain.""" def execute_staking_action(self, chain_descriptor: str, action_id: str, request_body): + """Execute staking action on a chain.""" return self._post_request(f"/v1/staking/chains/{chain_descriptor}/{action_id}", request_body) - """Get all staking positions, optionally filtered by chain.""" def get_staking_positions(self, chain_descriptor: str = None): + """Get all staking positions, optionally filtered by chain.""" return self._get_request(f"/v1/staking/positions", query_params={"chainDescriptor": chain_descriptor} if chain_descriptor else None) - """Get a staking position by id.""" def get_staking_position(self, position_id: str): + """Get a staking position by id.""" return self._get_request(f"/v1/staking/positions/{position_id}") - """Get all staking validators, filtered by chain.""" def get_staking_validators(self, chain_descriptor: str): + """Get all staking validators, filtered by chain.""" return self._get_request(f"/v1/staking/validators/{chain_descriptor}") - """Approve staking provider terms of service.""" def approve_staking_provider(self, validator_provider_id: int): + """Approve staking provider terms of service.""" return self._post_request(f"/v1/staking/providers/approveTermsOfService", body={"validatorProviderId": validator_provider_id}) @@ -154,12 +154,12 @@ def get_nft(self, id: str): return self._get_request(url) def get_nfts( - self, - ids: List[str], - page_cursor: str = "", - page_size: int = 100, - sort: List[GetNftsSortValues] = None, - order: OrderValues = None, + self, + ids: List[str], + page_cursor: str = "", + page_size: int = 100, + sort: List[GetNftsSortValues] = None, + order: OrderValues = None, ): """ Example list: "[1,2,3,4]" @@ -200,7 +200,7 @@ def refresh_nft_metadata(self, id: str): return self._put_request(path=url) def refresh_nft_ownership_by_vault( - self, blockchain_descriptor: str, vault_account_id: str + self, blockchain_descriptor: str, vault_account_id: str ): """ @@ -372,11 +372,11 @@ def get_supported_assets(self): return self._get_request("/v1/supported_assets") def get_vault_accounts( - self, - name_prefix=None, - name_suffix=None, - min_amount_threshold=None, - assetId=None, + self, + name_prefix=None, + name_suffix=None, + min_amount_threshold=None, + assetId=None, ): """Gets all vault accounts for your tenant @@ -409,7 +409,7 @@ def get_vault_accounts( return self._get_request(url) def get_vault_accounts_with_page_info( - self, paged_vault_accounts_request_filters: PagedVaultAccountsRequestFilters + self, paged_vault_accounts_request_filters: PagedVaultAccountsRequestFilters ): """Gets a page of vault accounts for your tenant according to filters given @@ -547,7 +547,7 @@ def get_vault_account_asset(self, vault_account_id, asset_id): return self._get_request(f"/v1/vault/accounts/{vault_account_id}/{asset_id}") def refresh_vault_asset_balance( - self, vault_account_id, asset_id, idempotency_key=None + self, vault_account_id, asset_id, idempotency_key=None ): """Gets a single vault account asset after forcing refresh from the blockchain Args: @@ -584,12 +584,12 @@ def get_unspent_inputs(self, vault_account_id, asset_id): ) def generate_new_address( - self, - vault_account_id, - asset_id, - description=None, - customer_ref_id=None, - idempotency_key=None, + self, + vault_account_id, + asset_id, + description=None, + customer_ref_id=None, + idempotency_key=None, ): """Generates a new address for an asset in a vault account @@ -608,7 +608,7 @@ def generate_new_address( ) def set_address_description( - self, vault_account_id, asset_id, address, tag=None, description=None + self, vault_account_id, asset_id, address, tag=None, description=None ): """Sets the description of an existing address @@ -636,11 +636,11 @@ def get_network_connections(self): return self._get_request("/v1/network_connections") def create_network_connection( - self, - local_network_id: str, - remote_network_id: str, - routing_policy=None, - idempotency_key=None, + self, + local_network_id: str, + remote_network_id: str, + routing_policy=None, + idempotency_key=None, ): """Creates a network connection Args: @@ -674,7 +674,7 @@ def remove_network_connection(self, connection_id: str): return self._delete_request(f"/v1/network_connections/{connection_id}") def set_network_connection_routing_policy( - self, connection_id: str, routing_policy=None + self, connection_id: str, routing_policy=None ): """Sets routing policy for a network connection Args: @@ -812,7 +812,7 @@ def get_exchange_account_asset(self, exchange_account_id, asset_id): ) def transfer_to_subaccount( - self, exchange_account_id, subaccount_id, asset_id, amount, idempotency_key=None + self, exchange_account_id, subaccount_id, asset_id, amount, idempotency_key=None ): """Transfer to a subaccount from a main exchange account @@ -832,7 +832,7 @@ def transfer_to_subaccount( ) def transfer_from_subaccount( - self, exchange_account_id, subaccount_id, asset_id, amount, idempotency_key=None + self, exchange_account_id, subaccount_id, asset_id, amount, idempotency_key=None ): """Transfer from a subaccount to a main exchange account @@ -902,18 +902,18 @@ def deposit_from_linked_dda(self, account_id, amount, idempotency_key=None): ) def get_transactions_with_page_info( - self, - before=0, - after=None, - status=None, - limit=None, - txhash=None, - assets=None, - source_type=None, - source_id=None, - dest_type=None, - dest_id=None, - next_or_previous_path=None, + self, + before=0, + after=None, + status=None, + limit=None, + txhash=None, + assets=None, + source_type=None, + source_id=None, + dest_type=None, + dest_id=None, + next_or_previous_path=None, ): """Gets a list of transactions matching the given filters or path. Note that "next_or_previous_path" is mutually exclusive with other parameters. @@ -968,18 +968,18 @@ def get_transactions_with_page_info( ) def get_transactions( - self, - before=0, - after=0, - status=None, - limit=None, - order_by=None, - txhash=None, - assets=None, - source_type=None, - source_id=None, - dest_type=None, - dest_id=None, + self, + before=0, + after=0, + status=None, + limit=None, + order_by=None, + txhash=None, + assets=None, + source_type=None, + source_id=None, + dest_type=None, + dest_id=None, ): """Gets a list of transactions matching the given filters @@ -1018,19 +1018,19 @@ def get_transactions( ) def _get_transactions( - self, - before, - after, - status, - limit, - order_by, - txhash, - assets, - source_type, - source_id, - dest_type, - dest_id, - page_mode=False, + self, + before, + after, + status, + limit, + order_by, + txhash, + assets, + source_type, + source_id, + dest_type, + dest_id, + page_mode=False, ): path = "/v1/transactions" params = {} @@ -1156,14 +1156,14 @@ def get_fee_for_asset(self, asset_id): return self._get_request(f"/v1/estimate_network_fee?assetId={asset_id}") def estimate_fee_for_transaction( - self, - asset_id, - amount, - source, - destination=None, - tx_type=TRANSACTION_TRANSFER, - idempotency_key=None, - destinations=None, + self, + asset_id, + amount, + source, + destination=None, + tx_type=TRANSACTION_TRANSFER, + idempotency_key=None, + destinations=None, ): """Estimates transaction fee @@ -1195,7 +1195,7 @@ def estimate_fee_for_transaction( if destination: if not isinstance( - destination, (TransferPeerPath, DestinationTransferPeerPath) + destination, (TransferPeerPath, DestinationTransferPeerPath) ): raise FireblocksApiException( "Expected transaction fee estimation destination of type DestinationTransferPeerPath or TransferPeerPath, but got type: " @@ -1227,7 +1227,7 @@ def cancel_transaction_by_id(self, txid, idempotency_key=None): ) def drop_transaction( - self, txid, fee_level=None, requested_fee=None, idempotency_key=None + self, txid, fee_level=None, requested_fee=None, idempotency_key=None ): """Drops the selected transaction from the blockchain by replacing it with a 0 ETH transaction to itself @@ -1250,12 +1250,12 @@ def drop_transaction( ) def create_vault_account( - self, - name, - hiddenOnUI=False, - customer_ref_id=None, - autoFuel=False, - idempotency_key=None, + self, + name, + hiddenOnUI=False, + customer_ref_id=None, + autoFuel=False, + idempotency_key=None, ): """Creates a new vault account. @@ -1360,7 +1360,7 @@ def activate_vault_asset(self, vault_account_id, asset_id, idempotency_key=None) ) def set_vault_account_customer_ref_id( - self, vault_account_id, customer_ref_id, idempotency_key=None + self, vault_account_id, customer_ref_id, idempotency_key=None ): """Sets an AML/KYT customer reference ID for the vault account @@ -1377,12 +1377,12 @@ def set_vault_account_customer_ref_id( ) def set_vault_account_customer_ref_id_for_address( - self, - vault_account_id, - asset_id, - address, - customer_ref_id=None, - idempotency_key=None, + self, + vault_account_id, + asset_id, + address, + customer_ref_id=None, + idempotency_key=None, ): """Sets an AML/KYT customer reference ID for the given address @@ -1409,7 +1409,7 @@ def create_contract_wallet(self, name, idempotency_key=None): return self._post_request("/v1/contracts", {"name": name}, idempotency_key) def create_contract_wallet_asset( - self, wallet_id, assetId, address, tag=None, idempotency_key=None + self, wallet_id, assetId, address, tag=None, idempotency_key=None ): """Creates a new contract wallet asset @@ -1456,7 +1456,7 @@ def create_internal_wallet(self, name, customer_ref_id=None, idempotency_key=Non ) def create_external_wallet_asset( - self, wallet_id, asset_id, address, tag=None, idempotency_key=None + self, wallet_id, asset_id, address, tag=None, idempotency_key=None ): """Creates a new asset within an exiting external wallet @@ -1477,7 +1477,7 @@ def create_external_wallet_asset( ) def create_internal_wallet_asset( - self, wallet_id, asset_id, address, tag=None, idempotency_key=None + self, wallet_id, asset_id, address, tag=None, idempotency_key=None ): """Creates a new asset within an exiting internal wallet @@ -1498,30 +1498,30 @@ def create_internal_wallet_asset( ) def create_transaction( - self, - asset_id=None, - amount=None, - source=None, - destination=None, - fee=None, - gas_price=None, - wait_for_status=False, - tx_type=TRANSACTION_TRANSFER, - note=None, - network_fee=None, - customer_ref_id=None, - replace_tx_by_hash=None, - extra_parameters=None, - destinations=None, - fee_level=None, - fail_on_low_fee=None, - max_fee=None, - gas_limit=None, - idempotency_key=None, - external_tx_id=None, - treat_as_gross_amount=None, - force_sweep=None, - priority_fee=None, + self, + asset_id=None, + amount=None, + source=None, + destination=None, + fee=None, + gas_price=None, + wait_for_status=False, + tx_type=TRANSACTION_TRANSFER, + note=None, + network_fee=None, + customer_ref_id=None, + replace_tx_by_hash=None, + extra_parameters=None, + destinations=None, + fee_level=None, + fail_on_low_fee=None, + max_fee=None, + gas_limit=None, + idempotency_key=None, + external_tx_id=None, + treat_as_gross_amount=None, + force_sweep=None, + priority_fee=None, ): """Creates a new transaction @@ -1599,7 +1599,7 @@ def create_transaction( if destination: if not isinstance( - destination, (TransferPeerPath, DestinationTransferPeerPath) + destination, (TransferPeerPath, DestinationTransferPeerPath) ): raise FireblocksApiException( "Expected transaction destination of type DestinationTransferPeerPath or TransferPeerPath, but got type: " @@ -1698,7 +1698,7 @@ def delete_external_wallet_asset(self, wallet_id, asset_id): return self._delete_request(f"/v1/external_wallets/{wallet_id}/{asset_id}") def set_customer_ref_id_for_internal_wallet( - self, wallet_id, customer_ref_id=None, idempotency_key=None + self, wallet_id, customer_ref_id=None, idempotency_key=None ): """Sets an AML/KYT customer reference ID for the specific internal wallet @@ -1715,7 +1715,7 @@ def set_customer_ref_id_for_internal_wallet( ) def set_customer_ref_id_for_external_wallet( - self, wallet_id, customer_ref_id=None, idempotency_key=None + self, wallet_id, customer_ref_id=None, idempotency_key=None ): """Sets an AML/KYT customer reference ID for the specific external wallet @@ -1737,7 +1737,7 @@ def get_transfer_tickets(self): return self._get_request("/v1/transfer_tickets") def create_transfer_ticket( - self, terms, external_ticket_id=None, description=None, idempotency_key=None + self, terms, external_ticket_id=None, description=None, idempotency_key=None ): """Creates a new transfer ticket @@ -1797,7 +1797,7 @@ def cancel_transfer_ticket(self, ticket_id, idempotency_key=None): ) def execute_ticket_term( - self, ticket_id, term_id, source=None, idempotency_key=None + self, ticket_id, term_id, source=None, idempotency_key=None ): """Initiate a transfer ticket transaction @@ -1824,7 +1824,7 @@ def execute_ticket_term( ) def set_confirmation_threshold_for_txid( - self, txid, required_confirmations_number, idempotency_key=None + self, txid, required_confirmations_number, idempotency_key=None ): """Set the required number of confirmations for transaction @@ -1841,7 +1841,7 @@ def set_confirmation_threshold_for_txid( ) def set_confirmation_threshold_for_txhash( - self, txhash, required_confirmations_number, idempotency_key=None + self, txhash, required_confirmations_number, idempotency_key=None ): """Set the required number of confirmations for transaction by txhash @@ -1876,7 +1876,7 @@ def get_public_key_info(self, algorithm, derivation_path, compressed=None): return self._get_request(url) def get_public_key_info_for_vault_account( - self, asset_id, vault_account_id, change, address_index, compressed=None + self, asset_id, vault_account_id, change, address_index, compressed=None ): """Get the public key information for a vault account @@ -1895,13 +1895,13 @@ def get_public_key_info_for_vault_account( return self._get_request(url) def allocate_funds_to_private_ledger( - self, - vault_account_id, - asset, - allocation_id, - amount, - treat_as_gross_amount=None, - idempotency_key=None, + self, + vault_account_id, + asset, + allocation_id, + amount, + treat_as_gross_amount=None, + idempotency_key=None, ): """Allocate funds from your default balance to a private ledger @@ -1927,7 +1927,7 @@ def allocate_funds_to_private_ledger( ) def deallocate_funds_from_private_ledger( - self, vault_account_id, asset, allocation_id, amount, idempotency_key=None + self, vault_account_id, asset, allocation_id, amount, idempotency_key=None ): """deallocate funds from a private ledger to your default balance @@ -1960,7 +1960,7 @@ def get_gas_station_info(self, asset_id=None): return self._get_request(url) def set_gas_station_configuration( - self, gas_threshold, gas_cap, max_gas_price=None, asset_id=None + self, gas_threshold, gas_cap, max_gas_price=None, asset_id=None ): """Set configuration of the Gas Station account @@ -1985,7 +1985,7 @@ def set_gas_station_configuration( return self._put_request(url, body) def get_vault_assets_balance( - self, account_name_prefix=None, account_name_suffix=None + self, account_name_prefix=None, account_name_suffix=None ): """Gets vault assets accumulated balance @@ -2022,7 +2022,7 @@ def get_vault_balance_by_asset(self, asset_id=None): return self._get_request(url) def create_raw_transaction( - self, raw_message, source=None, asset_id=None, note=None + self, raw_message, source=None, asset_id=None, note=None ): """Creates a new raw transaction with the specified parameters @@ -2053,7 +2053,7 @@ def create_raw_transaction( ) def get_max_spendable_amount( - self, vault_account_id, asset_id, manual_signing=False + self, vault_account_id, asset_id, manual_signing=False ): """Get max spendable amount per asset and vault. @@ -2110,7 +2110,7 @@ def resend_webhooks(self): return self._post_request("/v1/webhooks/resend") def resend_transaction_webhooks_by_id( - self, tx_id, resend_created, resend_status_updated + self, tx_id, resend_created, resend_status_updated ): """Resend webhooks of transaction @@ -2238,7 +2238,7 @@ def settle_off_exchange_by_id(self, off_exchange_id, idempotency_key=None): return self._post_request(url, {}, idempotency_key) def set_fee_payer_configuration( - self, base_asset, fee_payer_account_id, idempotency_key=None + self, base_asset, fee_payer_account_id, idempotency_key=None ): """ Setting fee payer configuration for base asset @@ -2274,7 +2274,7 @@ def remove_fee_payer_configuration(self, base_asset): return self._delete_request(url) def get_web3_connections( - self, pageCursor=None, pageSize=None, sort=None, filter=None, order=None + self, pageCursor=None, pageSize=None, sort=None, filter=None, order=None ): """ Get all signer connections of the current user @@ -2297,12 +2297,12 @@ def get_web3_connections( return self._get_request(url) def create_web3_connection( - self, - vault_account_id: str, - uri: str, - chain_ids: List[str], - fee_level: str = "MEDIUM", - idempotency_key: str = None, + self, + vault_account_id: str, + uri: str, + chain_ids: List[str], + fee_level: str = "MEDIUM", + idempotency_key: str = None, ): """ Initiate a new signer connection @@ -2762,7 +2762,7 @@ def _put_request(self, path, body=None, query_params=None): headers=headers, data=json.dumps(body), timeout=self.timeout, - ) + ) return handle_response(response) def _patch_request(self, path, body=None):