Skip to content

Commit

Permalink
feat: remove find_ouptuts method (#835)
Browse files Browse the repository at this point in the history
* feat: remove find_ouptuts method

* leftovers

* clippy

* Update bindings/nodejs/CHANGELOG.md

Co-authored-by: Thoralf-M <[email protected]>

* address comments

* Update sdk/CHANGELOG.md

Co-authored-by: Thoralf-M <[email protected]>

---------

Co-authored-by: Thoralf-M <[email protected]>
  • Loading branch information
qrayven and Thoralf-M authored Jul 21, 2023
1 parent 8b3eaf7 commit 8492702
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 91 deletions.
9 changes: 0 additions & 9 deletions bindings/core/src/method/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,6 @@ pub enum ClientMethod {
/// Amount
amount: u64,
},
/// Find all outputs based on the requests criteria. This method will try to query multiple nodes if
/// the request amount exceeds individual node limit.
#[serde(rename_all = "camelCase")]
FindOutputs {
/// Output IDs
output_ids: Vec<OutputId>,
/// Addresses
addresses: Vec<Bech32Address>,
},
/// Reattaches blocks for provided block id. Blocks can be reattached only if they are valid and haven't been
/// confirmed for a while.
#[serde(rename_all = "camelCase")]
Expand Down
9 changes: 0 additions & 9 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
.map(UtxoInputDto::from)
.collect(),
),
ClientMethod::FindOutputs { output_ids, addresses } => {
let outputs_response = client
.find_outputs(&output_ids, &addresses)
.await?
.iter()
.map(OutputWithMetadataResponse::from)
.collect();
Response::Outputs(outputs_response)
}
ClientMethod::Reattach { block_id } => {
let (block_id, block) = client.reattach(&block_id).await?;
Response::Reattached((block_id, BlockDto::from(&block)))
Expand Down
1 change: 0 additions & 1 deletion bindings/core/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ pub enum Response {
/// - [`GetOutputMetadata`](crate::method::ClientMethod::GetOutputMetadata)
OutputMetadata(OutputMetadata),
/// Response for:
/// - [`FindOutputs`](crate::method::ClientMethod::FindOutputs)
/// - [`GetOutputs`](crate::method::ClientMethod::GetOutputs)
/// - [`GetOutputsIgnoreErrors`](crate::method::ClientMethod::GetOutputsIgnoreErrors)
Outputs(Vec<OutputWithMetadataResponse>),
Expand Down
1 change: 1 addition & 0 deletions bindings/nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `CommonOutput::{setNativeTokens, setFeatures}`;
- `ImmutableFeaturesOutput::setImmutableFeatures`;
- `StateMetadataOutput::setStateMetadata`;
- `Client::findOutputs()` method;

### Fixed

Expand Down
20 changes: 0 additions & 20 deletions bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,26 +237,6 @@ export class Client {
return plainToInstance(UTXOInput, parsed.payload);
}

/**
* Find all outputs based on the requests criteria. This method will try to query multiple nodes if
* the request amount exceeds individual node limit.
*/
async findOutputs(
outputIds: string[],
addresses: string[],
): Promise<OutputResponse[]> {
const response = await this.methodHandler.callMethod({
name: 'findOutputs',
data: {
outputIds,
addresses,
},
});

const parsed = JSON.parse(response) as Response<OutputResponse[]>;
return plainToInstance(OutputResponse, parsed.payload);
}

/**
* Prepare a transaction for signing
*/
Expand Down
8 changes: 0 additions & 8 deletions bindings/nodejs/lib/types/client/bridge/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ export interface __FindInputsMethod__ {
};
}

export interface __FindOutputsMethod__ {
name: 'findOutputs';
data: {
outputIds: string[];
addresses: string[];
};
}

export interface __PrepareTransactionMethod__ {
name: 'prepareTransaction';
data: {
Expand Down
2 changes: 0 additions & 2 deletions bindings/nodejs/lib/types/client/bridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type {
__GetBlockMethod__,
__GetBlockMetadataMethod__,
__FindInputsMethod__,
__FindOutputsMethod__,
__PrepareTransactionMethod__,
__SignTransactionMethod__,
__PostBlockPayloadMethod__,
Expand Down Expand Up @@ -82,7 +81,6 @@ export type __ClientMethods__ =
| __GetBlockMethod__
| __GetBlockMetadataMethod__
| __FindInputsMethod__
| __FindOutputsMethod__
| __PrepareTransactionMethod__
| __SignTransactionMethod__
| __SignatureUnlockMethod__
Expand Down
1 change: 1 addition & 0 deletions bindings/python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `Wallet::{generate_mnemonic(), verify_mnemonic()}` since they're available from `Utils`;
- `HD_WALLET_TYPE`, `HARDEN_MASK` constants;
- `Client::find_outputs()` method;

### Fixed

Expand Down
13 changes: 0 additions & 13 deletions bindings/python/iota_sdk/client/_high_level_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,6 @@ def find_inputs(self, addresses: List[str], amount: int):
'amount': amount
})

def find_outputs(self, output_ids: List[OutputId], addresses: List[str]):
"""Find all outputs based on the requests criteria. This method will try to query multiple nodes if
the request amount exceeds individual node limit.
Args:
output_ids: A list of included output ids.
addresses: A list of included addresses.
"""
return self._call_method('findOutputs', {
'outputIds': output_ids,
'addresses': addresses
})

def reattach(self, block_id: HexStr) -> List[HexStr | Block]:
"""Reattaches blocks for a provided block id. Blocks can be reattached only if they are valid and
haven't been confirmed for a while .
Expand Down
1 change: 1 addition & 0 deletions sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `ProtocolParametersDto`, `NetworkInfoDto`, `OutputMetadataDto` in favor of base types;
- `serde` derives for types with explicit Dtos;
- More fields that are considered empty are no longer serialized;
- `Client::find_outputs()` method;

### Fixed

Expand Down
30 changes: 1 addition & 29 deletions sdk/src/client/api/high_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
block::{
address::Bech32Address,
input::{Input, UtxoInput, INPUT_COUNT_MAX},
output::{OutputId, OutputWithMetadata},
output::OutputWithMetadata,
parent::Parents,
payload::{
transaction::{TransactionEssence, TransactionId},
Expand Down Expand Up @@ -226,34 +226,6 @@ impl Client {
Ok(selected_inputs)
}

/// Find all outputs based on the requests criteria. This method will try to query multiple nodes if
/// the request amount exceeds individual node limit.
pub async fn find_outputs(
&self,
output_ids: &[OutputId],
addresses: &[Bech32Address],
) -> Result<Vec<OutputWithMetadata>> {
let mut output_responses = self.get_outputs(output_ids).await?;

// Use `get_address()` API to get the address outputs first,
// then collect the `UtxoInput` in the HashSet.
for address in addresses {
// Get output ids of outputs that can be controlled by this address without further unlock constraints
let output_ids_response = self
.basic_output_ids([
QueryParameter::Address(*address),
QueryParameter::HasExpiration(false),
QueryParameter::HasTimelock(false),
QueryParameter::HasStorageDepositReturn(false),
])
.await?;

output_responses.extend(self.get_outputs(&output_ids_response.items).await?);
}

Ok(output_responses.clone())
}

/// Reattaches blocks for provided block id. Blocks can be reattached only if they are valid and haven't been
/// confirmed for a while.
pub async fn reattach(&self, block_id: &BlockId) -> Result<(BlockId, Block)> {
Expand Down

0 comments on commit 8492702

Please sign in to comment.