Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove metadata from output endpoint #673

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 0 additions & 106 deletions .github/workflows/bindings-wallet-nodejs.yml

This file was deleted.

6 changes: 3 additions & 3 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
ClientMethod::GetBlockRaw { block_id } => Response::BlockRaw(client.get_block_raw(&block_id).await?),
ClientMethod::GetOutput { output_id } => Response::OutputWithMetadataResponse(
client
.get_output(&output_id)
.get_output_with_metadata(&output_id)
.await
.map(OutputWithMetadataResponse::from)?,
),
Expand Down Expand Up @@ -329,7 +329,7 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
ClientMethod::FoundryOutputId { foundry_id } => Response::OutputId(client.foundry_output_id(foundry_id).await?),
ClientMethod::GetOutputs { output_ids } => {
let outputs_response = client
.get_outputs(&output_ids)
.get_outputs_with_metadata(&output_ids)
.await?
.iter()
.map(OutputWithMetadataResponse::from)
Expand All @@ -338,7 +338,7 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
}
ClientMethod::GetOutputsIgnoreErrors { output_ids } => {
let outputs_response = client
.get_outputs_ignore_errors(&output_ids)
.get_outputs_with_metadata_ignore_errors(&output_ids)
.await?
.iter()
.map(OutputWithMetadataResponse::from)
Expand Down
14 changes: 6 additions & 8 deletions sdk/examples/client/output/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,16 @@ async fn main() -> Result<()> {
let output_ids_response = client
.basic_output_ids([QueryParameter::Address(bech32_nft_address)])
.await?;
let output_with_meta = client.get_output(&output_ids_response.items[0]).await?;
let output = client.get_output(&output_ids_response.items[0]).await?;

let block = client
.block()
.with_secret_manager(&secret_manager)
.with_input(nft_output_id.into())?
.with_input(output_ids_response.items[0].into())?
.with_outputs([
NftOutputBuilder::new_with_amount(1_000_000 + output_with_meta.output().amount(), nft_id)
.add_unlock_condition(AddressUnlockCondition::new(bech32_nft_address))
.finish_output(token_supply)?,
])?
.with_outputs([NftOutputBuilder::new_with_amount(1_000_000 + output.amount(), nft_id)
.add_unlock_condition(AddressUnlockCondition::new(bech32_nft_address))
.finish_output(token_supply)?])?
.finish()
.await?;

Expand All @@ -113,8 +111,8 @@ async fn main() -> Result<()> {
//////////////////////////////////

let nft_output_id = get_nft_output_id(block.payload().unwrap())?;
let output_with_meta = client.get_output(&nft_output_id).await?;
let outputs = [BasicOutputBuilder::new_with_amount(output_with_meta.output().amount())
let output = client.get_output(&nft_output_id).await?;
let outputs = [BasicOutputBuilder::new_with_amount(output.amount())
.add_unlock_condition(AddressUnlockCondition::new(bech32_nft_address))
.finish_output(token_supply)?];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a> ClientBlockBuilder<'a> {
.items,
);

self.client.get_outputs(&output_ids).await
self.client.get_outputs_with_metadata(&output_ids).await
}

/// Searches inputs for provided outputs, by requesting the outputs from the account addresses or for
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/client/api/block_builder/input_selection/manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'a> ClientBlockBuilder<'a> {

if let Some(inputs) = &self.inputs {
for input in inputs {
let output_with_meta = self.client.get_output(input.output_id()).await?;
let output_with_meta = self.client.get_output_with_metadata(input.output_id()).await?;
Alex6323 marked this conversation as resolved.
Show resolved Hide resolved

if !output_with_meta.metadata().is_spent() {
let alias_transition = is_alias_transition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<'a> ClientBlockBuilder<'a> {
}
}) {
let output_id = self.client.alias_output_id(*alias_id).await?;
let output_with_meta = self.client.get_output(&output_id).await?;
let output_with_meta = self.client.get_output_with_metadata(&output_id).await?;
if let Output::Alias(alias_output) = output_with_meta.output() {
// State transition if we add them to inputs
let unlock_address = alias_output.state_controller_address();
Expand Down Expand Up @@ -156,7 +156,7 @@ impl<'a> ClientBlockBuilder<'a> {
}
}) {
let output_id = self.client.nft_output_id(*nft_id).await?;
let output_with_meta = self.client.get_output(&output_id).await?;
let output_with_meta = self.client.get_output_with_metadata(&output_id).await?;
if let Output::Nft(nft_output) = output_with_meta.output() {
let unlock_address = nft_output
.unlock_conditions()
Expand Down
10 changes: 5 additions & 5 deletions sdk/src/client/api/block_builder/input_selection/utxo_chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub(crate) async fn get_alias_and_nft_outputs_recursively(
match unlock_address {
Address::Alias(address) => {
let input_id = client.alias_output_id(*address.alias_id()).await?;
let input = client.get_output(&input_id).await?;
let input = client.get_output_with_metadata(&input_id).await?;
Alex6323 marked this conversation as resolved.
Show resolved Hide resolved
if let Output::Alias(alias_input) = input.output() {
// State transition if we add them to inputs
let alias_unlock_address = alias_input.state_controller_address();
Expand All @@ -72,7 +72,7 @@ pub(crate) async fn get_alias_and_nft_outputs_recursively(
}
Address::Nft(address) => {
let input_id = client.nft_output_id(*address.nft_id()).await?;
let input = client.get_output(&input_id).await?;
let input = client.get_output_with_metadata(&input_id).await?;
if let Output::Nft(nft_input) = input.output() {
let unlock_address = nft_input
.unlock_conditions()
Expand Down Expand Up @@ -120,7 +120,7 @@ impl<'a> ClientBlockBuilder<'a> {
// Check if the transaction is a governance_transition, by checking if the new index is the same
// as the previous index
let output_id = client.alias_output_id(*alias_output.alias_id()).await?;
let input = client.get_output(&output_id).await?;
let input = client.get_output_with_metadata(&output_id).await?;
if let Output::Alias(alias_input) = input.output() {
// A governance transition is identified by an unchanged State Index in next
// state.
Expand All @@ -136,7 +136,7 @@ impl<'a> ClientBlockBuilder<'a> {
// If the id is null then this output creates it and we can't have a previous output
if !nft_output.nft_id().is_null() {
let output_id = client.nft_output_id(*nft_output.nft_id()).await?;
let input = client.get_output(&output_id).await?;
let input = client.get_output_with_metadata(&output_id).await?;
if let Output::Nft(nft_input) = input.output() {
let unlock_address = nft_input
.unlock_conditions()
Expand All @@ -149,7 +149,7 @@ impl<'a> ClientBlockBuilder<'a> {
Output::Foundry(foundry_output) => {
// if it's the first foundry output, then we can't have it as input
if let Ok(output_id) = client.foundry_output_id(foundry_output.id()).await {
let input = client.get_output(&output_id).await?;
let input = client.get_output_with_metadata(&output_id).await?;
if let Output::Foundry(foundry_input_output) = input.output() {
utxo_chains.push((Address::Alias(*foundry_input_output.alias_address()), input));
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/client/api/consolidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Client {
])
.await?;

let basic_outputs_responses = self.get_outputs(&output_ids_response.items).await?;
let basic_outputs_responses = self.get_outputs_with_metadata(&output_ids_response.items).await?;

if !basic_outputs_responses.is_empty() {
// If we reach the same index again
Expand Down
8 changes: 4 additions & 4 deletions sdk/src/client/api/high_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Client {
})
.collect::<Vec<_>>();

self.get_outputs(&input_ids).await
self.get_outputs_with_metadata(&input_ids).await
}

/// A generic send function for easily sending transaction or tagged data blocks.
Expand Down Expand Up @@ -179,7 +179,7 @@ impl Client {
})
.and_then(|res| async {
let items = res.items;
self.get_outputs(&items).await
self.get_outputs_with_metadata(&items).await
})
.try_collect::<Vec<_>>()
.await?;
Expand Down Expand Up @@ -232,7 +232,7 @@ impl Client {
output_ids: &[OutputId],
addresses: &[Bech32Address],
) -> Result<Vec<OutputWithMetadata>> {
let mut output_responses = self.get_outputs(output_ids).await?;
let mut output_responses = self.get_outputs_with_metadata(output_ids).await?;

// Use `get_address()` API to get the address outputs first,
// then collect the `UtxoInput` in the HashSet.
Expand All @@ -247,7 +247,7 @@ impl Client {
])
.await?;

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

Ok(output_responses.clone())
Expand Down
Loading