Skip to content

Commit

Permalink
fixes + keep a previous name
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Jun 23, 2023
1 parent acd2df1 commit 1751f34
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 41 deletions.
6 changes: 3 additions & 3 deletions bindings/core/src/method_handler/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use iota_sdk::{
Error,
},
wallet::account::{
types::TransactionDto, Account, OutputDataDto, PreparedNativeTokenTransactionDto, TransactionOptions,
types::TransactionDto, Account, OutputDataDto, PreparedMintNativeTokenTransactionDto, TransactionOptions,
},
};
use primitive_types::U256;
Expand Down Expand Up @@ -178,7 +178,7 @@ pub(crate) async fn call_account_method_internal(account: &Account, method: Acco
options.map(TransactionOptions::try_from_dto).transpose()?,
)
.await?;
Response::PreparedNativeTokenTransaction(PreparedNativeTokenTransactionDto::from(&data))
Response::PreparedMintNativeTokenTransaction(PreparedMintNativeTokenTransactionDto::from(&data))
}
#[cfg(feature = "participation")]
AccountMethod::PrepareIncreaseVotingPower { amount } => {
Expand All @@ -199,7 +199,7 @@ pub(crate) async fn call_account_method_internal(account: &Account, method: Acco
let data = account
.prepare_create_native_token(params, options.map(TransactionOptions::try_from_dto).transpose()?)
.await?;
Response::PreparedNativeTokenTransaction(PreparedNativeTokenTransactionDto::from(&data))
Response::PreparedMintNativeTokenTransaction(PreparedMintNativeTokenTransactionDto::from(&data))
}
AccountMethod::PrepareOutput {
params,
Expand Down
4 changes: 2 additions & 2 deletions bindings/core/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use iota_sdk::{
wallet::{
account::{
types::{AccountAddress, AddressWithUnspentOutputs, Balance, OutputDataDto, TransactionDto},
PreparedNativeTokenTransactionDto,
PreparedMintNativeTokenTransactionDto,
},
message_interface::dtos::AccountDetailsDto,
},
Expand Down Expand Up @@ -336,7 +336,7 @@ pub enum Response {
/// Response for
/// - [`PrepareCreateNativeToken`](crate::method::AccountMethod::PrepareCreateNativeToken),
/// - [`PrepareMintNativeToken`](crate::method::AccountMethod::PrepareMintNativeToken),
PreparedNativeTokenTransaction(PreparedNativeTokenTransactionDto),
PreparedMintNativeTokenTransaction(PreparedMintNativeTokenTransactionDto),
/// Response for
/// - [`GetTransaction`](crate::method::AccountMethod::GetTransaction),
/// - [`GetIncomingTransaction`](crate::method::AccountMethod::GetIncomingTransaction)
Expand Down
4 changes: 1 addition & 3 deletions sdk/examples/how_tos/native_tokens/melt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ async fn main() -> Result<()> {

// Melt some of the circulating supply
let melt_amount = U256::from(MELT_AMOUNT);
let transaction = account
.melt_native_token(token_id, melt_amount, None)
.await?;
let transaction = account.melt_native_token(token_id, melt_amount, None).await?;
println!("Transaction sent: {}", transaction.transaction_id);

let block_id = account
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/wallet/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ pub use self::{
create_alias::CreateAliasParams,
minting::{
create_native_token::{
CreateNativeTokenParams, NativeTokenTransactionDto,
PreparedNativeTokenTransactionDto,
CreateNativeTokenParams, MintNativeTokenTransactionDto, PreparedMintNativeTokenTransactionDto,
},
mint_nfts::MintNftParams,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ pub struct CreateNativeTokenParams {
/// The result of a minting native token transaction
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NativeTokenTransaction {
pub struct MintNativeTokenTransaction {
pub token_id: TokenId,
pub transaction: Transaction,
}

/// Dto for NativeTokenTransaction
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NativeTokenTransactionDto {
pub struct MintNativeTokenTransactionDto {
pub token_id: TokenId,
pub transaction: TransactionDto,
}

impl From<&NativeTokenTransaction> for NativeTokenTransactionDto {
fn from(value: &NativeTokenTransaction) -> Self {
impl From<&MintNativeTokenTransaction> for MintNativeTokenTransactionDto {
fn from(value: &MintNativeTokenTransaction) -> Self {
Self {
token_id: value.token_id,
transaction: TransactionDto::from(&value.transaction),
Expand All @@ -65,21 +65,21 @@ impl From<&NativeTokenTransaction> for NativeTokenTransactionDto {
/// The result of preparing a minting native token transaction
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PreparedNativeTokenTransaction {
pub struct PreparedMintNativeTokenTransaction {
pub token_id: TokenId,
pub transaction: PreparedTransactionData,
}

/// Dto for PreparedNativeTokenTransaction
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PreparedNativeTokenTransactionDto {
pub struct PreparedMintNativeTokenTransactionDto {
pub token_id: TokenId,
pub transaction: PreparedTransactionDataDto,
}

impl From<&PreparedNativeTokenTransaction> for PreparedNativeTokenTransactionDto {
fn from(value: &PreparedNativeTokenTransaction) -> Self {
impl From<&PreparedMintNativeTokenTransaction> for PreparedMintNativeTokenTransactionDto {
fn from(value: &PreparedMintNativeTokenTransaction) -> Self {
Self {
token_id: value.token_id,
transaction: PreparedTransactionDataDto::from(&value.transaction),
Expand All @@ -103,7 +103,7 @@ where
/// foundry_metadata: None
/// };
///
/// let tx = account.mint_native_token(params, None,).await?;
/// let tx = account.create_native_token(params, None,).await?;
/// println!("Transaction created: {}", tx.transaction_id);
/// if let Some(block_id) = tx.block_id {
/// println!("Block sent: {}", block_id);
Expand All @@ -113,13 +113,13 @@ where
&self,
params: CreateNativeTokenParams,
options: impl Into<Option<TransactionOptions>> + Send,
) -> crate::wallet::Result<NativeTokenTransaction> {
) -> crate::wallet::Result<MintNativeTokenTransaction> {
let options = options.into();
let prepared = self.prepare_create_native_token(params, options.clone()).await?;

self.sign_and_submit_transaction(prepared.transaction, options)
.await
.map(|transaction| NativeTokenTransaction {
.map(|transaction| MintNativeTokenTransaction {
token_id: prepared.token_id,
transaction,
})
Expand All @@ -131,7 +131,7 @@ where
&self,
params: CreateNativeTokenParams,
options: impl Into<Option<TransactionOptions>> + Send,
) -> crate::wallet::Result<PreparedNativeTokenTransaction> {
) -> crate::wallet::Result<PreparedMintNativeTokenTransaction> {
log::debug!("[TRANSACTION] mint_native_token");
let rent_structure = self.client().get_rent_structure().await?;
let token_supply = self.client().get_token_supply().await?;
Expand Down Expand Up @@ -180,7 +180,7 @@ where

self.prepare_transaction(outputs, options)
.await
.map(|transaction| PreparedNativeTokenTransaction { token_id, transaction })
.map(|transaction| PreparedMintNativeTokenTransaction { token_id, transaction })
} else {
unreachable!("We checked if it's an alias output before")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
wallet::{
account::{
operations::transaction::high_level::minting::create_native_token::{
NativeTokenTransaction, PreparedNativeTokenTransaction,
MintNativeTokenTransaction, PreparedMintNativeTokenTransaction,
},
Account, TransactionOptions,
},
Expand Down Expand Up @@ -39,14 +39,14 @@ where
token_id: TokenId,
mint_amount: U256,
options: impl Into<Option<TransactionOptions>> + Send,
) -> crate::wallet::Result<NativeTokenTransaction> {
) -> crate::wallet::Result<MintNativeTokenTransaction> {
let options = options.into();
let prepared = self
.prepare_mint_native_token(token_id, mint_amount, options.clone())
.await?;
let transaction = self.sign_and_submit_transaction(prepared.transaction, options).await?;

Ok(NativeTokenTransaction {
Ok(MintNativeTokenTransaction {
token_id: prepared.token_id,
transaction,
})
Expand All @@ -59,7 +59,7 @@ where
token_id: TokenId,
mint_amount: U256,
options: impl Into<Option<TransactionOptions>> + Send,
) -> crate::wallet::Result<PreparedNativeTokenTransaction> {
) -> crate::wallet::Result<PreparedMintNativeTokenTransaction> {
log::debug!("[TRANSACTION] mint_native_token");

let account_details = self.details().await;
Expand Down Expand Up @@ -139,6 +139,6 @@ where

self.prepare_transaction(outputs, options)
.await
.map(|transaction| PreparedNativeTokenTransaction { token_id, transaction })
.map(|transaction| PreparedMintNativeTokenTransaction { token_id, transaction })
}
}
6 changes: 4 additions & 2 deletions sdk/src/wallet/message_interface/account_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ pub enum AccountMethod {
/// [`MinimumRequiredStorageDeposit`](crate::wallet::message_interface::Response::MinimumRequiredStorageDeposit)
MinimumRequiredStorageDeposit { output: OutputDto },
/// Mint more native token.
/// Expected response: [`NativeTokenTransaction`](crate::wallet::message_interface::Response::NativeTokenTransaction)
/// Expected response:
/// [`MintNativeTokenTransaction`](crate::wallet::message_interface::Response::MintNativeTokenTransaction)
#[serde(rename_all = "camelCase")]
MintNativeToken {
/// Native token id
Expand All @@ -264,7 +265,8 @@ pub enum AccountMethod {
options: Option<TransactionOptionsDto>,
},
/// Create a native token.
/// Expected response: [`NativeTokenTransaction`](crate::wallet::message_interface::Response::NativeTokenTransaction)
/// Expected response:
/// [`MintNativeTokenTransaction`](crate::wallet::message_interface::Response::MintNativeTokenTransaction)
#[serde(rename_all = "camelCase")]
CreateNativeToken {
params: CreateNativeTokenParams,
Expand Down
14 changes: 7 additions & 7 deletions sdk/src/wallet/message_interface/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::{
wallet::{
account::{
operations::transaction::{
high_level::minting::create_native_token::NativeTokenTransactionDto, TransactionOptions,
high_level::minting::create_native_token::MintNativeTokenTransactionDto, TransactionOptions,
},
types::{AccountIdentifier, TransactionDto},
OutputDataDto,
Expand Down Expand Up @@ -701,9 +701,9 @@ impl WalletMessageHandler {
options.map(TransactionOptions::try_from_dto).transpose()?,
)
.await?;
Ok(Response::NativeTokenTransaction(NativeTokenTransactionDto::from(
&transaction,
)))
Ok(Response::MintNativeTokenTransaction(
MintNativeTokenTransactionDto::from(&transaction),
))
})
.await
}
Expand All @@ -712,9 +712,9 @@ impl WalletMessageHandler {
let transaction = account
.create_native_token(params, options.map(TransactionOptions::try_from_dto).transpose()?)
.await?;
Ok(Response::NativeTokenTransaction(NativeTokenTransactionDto::from(
&transaction,
)))
Ok(Response::MintNativeTokenTransaction(
MintNativeTokenTransactionDto::from(&transaction),
))
})
.await
}
Expand Down
8 changes: 4 additions & 4 deletions sdk/src/wallet/message_interface/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
},
wallet::{
account::{
operations::transaction::high_level::minting::create_native_token::NativeTokenTransactionDto,
operations::transaction::high_level::minting::create_native_token::MintNativeTokenTransactionDto,
types::{address::AccountAddress, AddressWithUnspentOutputs, Balance, TransactionDto},
OutputDataDto,
},
Expand Down Expand Up @@ -130,7 +130,7 @@ pub enum Response {
SentTransaction(TransactionDto),
/// Response for
/// [`CreateNativeToken`](crate::wallet::message_interface::AccountMethod::CreateNativeToken),
NativeTokenTransaction(NativeTokenTransactionDto),
MintNativeTokenTransaction(MintNativeTokenTransactionDto),
/// Response for
/// [`IsStrongholdPasswordAvailable`](crate::wallet::message_interface::Message::IsStrongholdPasswordAvailable)
/// [`VerifyEd25519Signature`](crate::wallet::message_interface::account_method::AccountMethod::VerifyEd25519Signature)
Expand Down Expand Up @@ -229,8 +229,8 @@ impl Debug for Response {
}
Self::Balance(balance) => write!(f, "Balance({balance:?})"),
Self::SentTransaction(transaction) => write!(f, "SentTransaction({transaction:?})"),
Self::NativeTokenTransaction(native_token_transaction) => {
write!(f, "NativeTokenTransaction({native_token_transaction:?})")
Self::MintNativeTokenTransaction(mint_transaction) => {
write!(f, "MintNativeTokenTransaction({mint_transaction:?})")
}
Self::Bool(b) => {
write!(f, "Bool({b})")
Expand Down

0 comments on commit 1751f34

Please sign in to comment.