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

Rename prepare_transaction() to prepare_send_outputs() #2132

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
4 changes: 2 additions & 2 deletions bindings/core/src/method/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ pub enum WalletMethod {
// #[cfg_attr(docsrs, doc(cfg(feature = "participation")))]
// #[serde(rename_all = "camelCase")]
// PrepareStopParticipating { event_id: ParticipationEventId },
/// Prepare transaction.
/// Prepare to send outputs.
/// Expected response: [`PreparedTransaction`](crate::Response::PreparedTransaction)
PrepareTransaction {
PrepareSendOutputs {
outputs: Vec<Output>,
#[serde(default)]
options: Option<TransactionOptions>,
Expand Down
4 changes: 2 additions & 2 deletions bindings/core/src/method_handler/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ pub(crate) async fn call_wallet_method_internal(
// let data = wallet.prepare_stop_participating(event_id).await?;
// Response::PreparedTransaction(data)
// }
WalletMethod::PrepareTransaction { outputs, options } => {
let data = wallet.prepare_transaction(outputs, options).await?;
WalletMethod::PrepareSendOutputs { outputs, options } => {
let data = wallet.prepare_send_outputs(outputs, options).await?;
Response::PreparedTransaction(data)
}
// #[cfg(feature = "participation")]
Expand Down
2 changes: 1 addition & 1 deletion bindings/core/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ pub enum Response {
/// - [`PrepareSendNativeTokens`](crate::method::WalletMethod::PrepareSendNativeTokens),
/// - [`PrepareSendNft`](crate::method::WalletMethod::PrepareSendNft),
/// - [`PrepareStopParticipating`](crate::method::WalletMethod::PrepareStopParticipating)
/// - [`PrepareTransaction`](crate::method::WalletMethod::PrepareTransaction)
/// - [`PrepareSendOutputs`](crate::method::WalletMethod::PrepareSendOutputs)
/// - [`PrepareVote`](crate::method::WalletMethod::PrepareVote)
/// - [`PrepareImplicitAccountTransition`](crate::method::WalletMethod::PrepareImplicitAccountTransition)
PreparedTransaction(PreparedTransactionData),
Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/types/wallet/bridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import type {
__PrepareBeginStakingMethod__,
__PrepareExtendStakingMethod__,
__PrepareEndStakingMethod__,
__PrepareTransactionMethod__,
__PrepareSendOutputsMethod__,
__RegisterParticipationEventsMethod__,
__WaitForTransactionAcceptanceMethod__,
__SendMethod__,
Expand Down Expand Up @@ -112,7 +112,7 @@ export type __WalletMethod__ =
| __PrepareBeginStakingMethod__
| __PrepareExtendStakingMethod__
| __PrepareEndStakingMethod__
| __PrepareTransactionMethod__
| __PrepareSendOutputsMethod__
| __RegisterParticipationEventsMethod__
| __WaitForTransactionAcceptanceMethod__
| __SendMethod__
Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/types/wallet/bridge/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ export type __PrepareSendMethod__ = {
};
};

export type __PrepareTransactionMethod__ = {
name: 'prepareTransaction';
export type __PrepareSendOutputsMethod__ = {
name: 'prepareSendOutputs';
data: {
outputs: Output[];
options?: TransactionOptions;
Expand Down
35 changes: 5 additions & 30 deletions bindings/nodejs/lib/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1463,17 +1463,17 @@ export class Wallet {
}

/**
* Send a transaction.
* Send outputs.
*
* @param outputs Outputs to use in the transaction.
* @param options Additional transaction options.
* @returns The transaction data.
*/
async sendTransaction(
async sendOutputs(
outputs: Output[],
options?: TransactionOptions,
): Promise<TransactionWithMetadata> {
return (await this.prepareTransaction(outputs, options)).send();
return (await this.prepareSendOutputs(outputs, options)).send();
}

/**
Expand All @@ -1483,12 +1483,12 @@ export class Wallet {
* @param options Additional transaction options.
* @returns The prepared transaction data.
*/
async prepareTransaction(
async prepareSendOutputs(
outputs: Output[],
options?: TransactionOptions,
): Promise<PreparedTransaction> {
const response = await this.methodHandler.callMethod({
name: 'prepareTransaction',
name: 'prepareSendOutputs',
data: {
outputs,
options,
Expand Down Expand Up @@ -1682,31 +1682,6 @@ export class Wallet {
);
}

/**
* Send outputs in a transaction.
*
* @param outputs The outputs to send.
* @param transactionOptions Additional transaction options.
* @returns The sent transaction.
*/
async sendOutputs(
outputs: Output[],
transactionOptions?: TransactionOptions,
): Promise<TransactionWithMetadata> {
const response = await this.methodHandler.callMethod({
name: 'sendOutputs',
data: {
outputs,
options: transactionOptions,
},
});

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

/**
* Send mana.
*
Expand Down
23 changes: 6 additions & 17 deletions bindings/python/iota_sdk/wallet/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,18 +701,18 @@ def announce_candidacy(self, account_id: HexStr) -> BlockId:
}
))

def send_transaction(
def send_outputs(
self, outputs: List[Output], options: Optional[TransactionOptions] = None) -> TransactionWithMetadata:
"""Send a transaction.
"""Send outputs.
"""
return self.prepare_transaction(outputs, options).send()
return self.prepare_send_outputs(outputs, options).send()

def prepare_transaction(
def prepare_send_outputs(
self, outputs: List[Output], options: Optional[TransactionOptions] = None) -> PreparedTransaction:
"""Prepare transaction.
"""Prepare to send outputs.
"""
prepared = PreparedTransactionData.from_dict(self._call_method(
'prepareTransaction', {
'prepareSendOutputs', {
'outputs': outputs,
'options': options
}
Expand Down Expand Up @@ -792,17 +792,6 @@ def prepare_send_nft(self, params: List[SendNftParams],
))
return PreparedTransaction(self, prepared)

def send_outputs(
self, outputs: List[Output], options: Optional[TransactionOptions] = None) -> TransactionWithMetadata:
"""Send outputs in a transaction.
"""
return TransactionWithMetadata.from_dict(self._call_method(
'sendOutputs', {
'outputs': outputs,
'options': options,
}
))

def send_mana(
self, params: SendManaParams, options: Optional[TransactionOptions] = None) -> TransactionWithMetadata:
"""Send mana.
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/output_claiming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ where
}
}

self.prepare_transaction(
self.prepare_send_outputs(
// We only need to provide the NFT outputs, ISA automatically creates basic outputs as remainder outputs
nft_outputs_to_send,
TransactionOptions {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/output_consolidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
..Default::default()
});

self.prepare_transaction([], options).await
self.prepare_send_outputs([], options).await
}

/// Determines whether an output should be consolidated or not.
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/wallet/operations/participation/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
])
.finish_output()?;

self.prepare_transaction(
self.prepare_send_outputs(
[new_output],
Some(TransactionOptions {
// Only use previous voting output as input.
Expand Down Expand Up @@ -183,7 +183,7 @@ where
])
.finish_output()?;

self.prepare_transaction(
self.prepare_send_outputs(
[new_output],
Some(TransactionOptions {
// Only use previous voting output as input.
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/wallet/operations/participation/voting_power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where
),
};

self.prepare_transaction([new_output], tx_options).await
self.prepare_send_outputs([new_output], tx_options).await
}

/// Reduces an account's "voting power" by a given amount.
Expand Down Expand Up @@ -114,7 +114,7 @@ where
(new_output, Some(tagged_data_payload))
};

self.prepare_transaction(
self.prepare_send_outputs(
[new_output],
Some(TransactionOptions {
// Use the previous voting output and additionally others for possible additional required amount for
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/transaction/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ where
..Default::default()
};

self.prepare_transaction(vec![account], transaction_options.clone())
self.prepare_send_outputs(vec![account], transaction_options.clone())
.await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ where
*options.mana_allotments.entry(account_id).or_default() += mana;
}

self.prepare_transaction([], options).await
self.prepare_send_outputs([], options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ where
)?))
.finish_output()?];
// Transaction builder will detect that we're melting native tokens and add the required inputs if available
self.prepare_transaction(outputs, options).await
self.prepare_send_outputs(outputs, options).await
}

/// Find and return unspent `OutputData` for given `account_id` and `foundry_id`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ impl Wallet {

// The empty list of outputs is used. Outputs will be generated by
// the transaction builder algorithm based on the content of the [`Burn`] object.
self.prepare_transaction([], options).await
self.prepare_send_outputs([], options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ where

let outputs = [account_output_builder.finish_output()?];

self.prepare_transaction(outputs, options).await
self.prepare_send_outputs(outputs, options).await
}

/// Gets an existing account output.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where
.add_unlock_condition(AddressUnlockCondition::new(address))
.finish_output()?;

let transaction = self.prepare_transaction([output], options).await?;
let transaction = self.prepare_send_outputs([output], options).await?;

Ok(PreparedCreateDelegationTransaction {
delegation_id: DelegationId::from(&transaction.transaction.id().into_output_id(0)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ where
}
};

self.prepare_transaction(outputs, None).await
self.prepare_send_outputs(outputs, None).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ where
{
/// Creates a new foundry output with minted native tokens.
///
/// Calls [Wallet::prepare_transaction()](crate::wallet::Wallet::prepare_transaction) internally, the options may
/// Calls [Wallet::prepare_send_outputs()](crate::wallet::Wallet::prepare_send_outputs) internally, the options may
/// define the remainder value strategy or custom inputs.
/// ```ignore
/// let params = CreateNativeTokenParams {
Expand Down Expand Up @@ -141,7 +141,7 @@ where
foundry_builder.finish_output()?
}];

self.prepare_transaction(outputs, options)
self.prepare_send_outputs(outputs, options)
.await
.map(|transaction| PreparedCreateNativeTokenTransaction { token_id, transaction })
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ where

let outputs = [new_foundry_output_builder.finish_output()?];

self.prepare_transaction(outputs, options).await
self.prepare_send_outputs(outputs, options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where
{
/// Mints NFTs.
///
/// Calls [Wallet::prepare_transaction()](crate::wallet::Wallet::prepare_transaction) internally. The options may
/// Calls [Wallet::prepare_send_outputs()](crate::wallet::Wallet::prepare_send_outputs) internally. The options may
/// define the remainder value strategy or custom inputs. Note that addresses need to be bech32-encoded.
/// ```ignore
/// let nft_id: [u8; 38] =
Expand Down Expand Up @@ -207,6 +207,6 @@ where
outputs.push(nft_builder.finish_output()?);
}

self.prepare_transaction(outputs, options).await
self.prepare_send_outputs(outputs, options).await
}
}
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/transaction/high_level/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ where
}
}

self.prepare_transaction(outputs, options).await
self.prepare_send_outputs(outputs, options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ where

let output = output_builder.finish_output()?;

self.prepare_transaction(vec![output], options).await
self.prepare_send_outputs(vec![output], options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ where
)
}

self.prepare_transaction(outputs, options).await
self.prepare_send_outputs(outputs, options).await
}
}
4 changes: 2 additions & 2 deletions sdk/src/wallet/operations/transaction/high_level/send_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
ClientError: From<S::Error>,
{
/// Sends an NFT to the provided address.
/// Calls [Wallet::prepare_transaction()](crate::wallet::Wallet::prepare_transaction) internally. The
/// Calls [Wallet::prepare_send_outputs()](crate::wallet::Wallet::prepare_send_outputs) internally. The
/// options may define the remainder value strategy. Note that custom inputs will be replaced with the required
/// nft inputs and addresses need to be bech32-encoded.
/// ```ignore
Expand Down Expand Up @@ -106,6 +106,6 @@ where
};
}

self.prepare_transaction(outputs, options).await
self.prepare_send_outputs(outputs, options).await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ where
))
.finish_output()?;

let transaction = self.prepare_transaction([output], options).await?;
let transaction = self.prepare_send_outputs([output], options).await?;

Ok(transaction)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where
.with_features(features)
.finish_output()?;

let transaction = self.prepare_transaction([output], options).await?;
let transaction = self.prepare_send_outputs([output], options).await?;

Ok(transaction)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where

let output = output_builder.finish_output()?;

let transaction = self.prepare_transaction([output], options).await?;
let transaction = self.prepare_send_outputs([output], options).await?;

Ok(transaction)
}
Expand Down
Loading
Loading