Skip to content

Commit

Permalink
Rename Alias to Account (#706)
Browse files Browse the repository at this point in the history
* Rename Alias to Account

* More rename

* More rename

* More rename

* More rename

* More rename

* More rename

* More rename

* More rename

* More rename

* More rename

* More rename

* Last renames

* Disable yarn tests

* trigger

* Trigger

* Rename files

* Fix

* Update sdk/examples/wallet/16_destroy_account_output.rs

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

* More rename

* Update sdk/src/types/block/address/account.rs

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

* Update sdk/src/types/block/output/unlock_condition/immutable_account_address.rs

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

* Review comments

* More rename

* Update sdk/tests/types/address/account.rs

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

* Update sdk/tests/types/address/account.rs

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

* Update sdk/examples/wallet/16_destroy_account_output.rs

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

* Update sdk/src/wallet/account/operations/transaction/high_level/create_account.rs

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

* Add TODO

* Fix create_account_output_command rename

---------

Co-authored-by: Thoralf-M <[email protected]>
  • Loading branch information
thibault-martinez and Thoralf-M committed Jul 17, 2023
1 parent f79c7d6 commit e0e68e4
Show file tree
Hide file tree
Showing 119 changed files with 2,411 additions and 2,352 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/bindings-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ jobs:
working-directory: bindings/nodejs/
run: yarn rebuild

- name: Run Yarn Test
working-directory: bindings/nodejs/
run: yarn test
# TODO reenable https://github.com/iotaledger/iota-sdk/issues/647
# - name: Run Yarn Test
# working-directory: bindings/nodejs/
# run: yarn test

- name: Yarn Build Examples
working-directory: bindings/nodejs/examples/
Expand Down
24 changes: 12 additions & 12 deletions bindings/core/src/message_interface_old/account_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ use iota_sdk::{
dto::{OutputDto, TokenSchemeDto},
feature::dto::FeatureDto,
unlock_condition::dto::UnlockConditionDto,
AliasId, FoundryId, NativeToken, NftId, OutputId, TokenId,
AccountId, FoundryId, NativeToken, NftId, OutputId, TokenId,
},
payload::transaction::TransactionId,
signature::dto::Ed25519SignatureDto,
},
utils::serde::bip44::Bip44Def,
wallet::{
account::{
CreateAliasParams, CreateNativeTokenParams, FilterOptions, MintNftParams, OutputParams, OutputsToClaim,
CreateAccountParams, CreateNativeTokenParams, FilterOptions, MintNftParams, OutputParams, OutputsToClaim,
SyncOptions, TransactionOptionsDto,
},
SendNativeTokensParams, SendNftParams, SendParams,
Expand All @@ -41,15 +41,15 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "name", content = "data", rename_all = "camelCase")]
pub enum AccountMethod {
/// Build an AliasOutput.
/// Build an AccountOutput.
/// Expected response: [`Output`](crate::wallet::message_interface::Response::Output)
#[allow(missing_docs)]
#[serde(rename_all = "camelCase")]
BuildAliasOutput {
BuildAccountOutput {
// If not provided, minimum storage deposit will be used
amount: Option<String>,
native_tokens: Option<Vec<NativeToken>>,
alias_id: AliasId,
account_id: AccountId,
state_index: Option<u32>,
state_metadata: Option<Vec<u8>>,
foundry_counter: Option<u32>,
Expand Down Expand Up @@ -127,24 +127,24 @@ pub enum AccountMethod {
force: bool,
output_consolidation_threshold: Option<usize>,
},
/// Create an alias output.
/// Create an account output.
/// Expected response: [`SentTransaction`](crate::wallet::message_interface::Response::SentTransaction)
#[serde(rename_all = "camelCase")]
CreateAliasOutput {
params: Option<CreateAliasParams>,
CreateAccountOutput {
params: Option<CreateAccountParams>,
options: Option<TransactionOptionsDto>,
},
/// Destroy an alias output. Outputs controlled by it will be swept before if they don't have a
/// Destroy an account output. Outputs controlled by it will be swept before if they don't have a
/// storage deposit return, timelock or expiration unlock condition. The amount and possible native tokens will be
/// sent to the governor address.
/// Expected response: [`SentTransaction`](crate::wallet::message_interface::Response::SentTransaction)
#[serde(rename_all = "camelCase")]
DestroyAlias {
alias_id: AliasId,
DestroyAccount {
account_id: AccountId,
options: Option<TransactionOptionsDto>,
},
/// Destroy a foundry output with a circulating supply of 0.
/// Native tokens in the foundry (minted by other foundries) will be transacted to the controlling alias
/// Native tokens in the foundry (minted by other foundries) will be transacted to the controlling account
/// Expected response: [`SentTransaction`](crate::wallet::message_interface::Response::SentTransaction)
#[serde(rename_all = "camelCase")]
DestroyFoundry {
Expand Down
18 changes: 9 additions & 9 deletions bindings/core/src/message_interface_old/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use iota_sdk::{
address::{Hrp, ToBech32Ext},
output::{
dto::{OutputBuilderAmountDto, OutputDto},
AliasOutput, BasicOutput, FoundryOutput, NativeToken, NftOutput, Output, Rent,
AccountOutput, BasicOutput, FoundryOutput, NativeToken, NftOutput, Output, Rent,
},
signature::Ed25519Signature,
ConvertTo, Error,
Expand Down Expand Up @@ -392,25 +392,25 @@ impl WalletMessageHandler {
let account = self.wallet.get_account(account_id.clone()).await?;

match method {
AccountMethod::BuildAliasOutput {
AccountMethod::BuildAccountOutput {
amount,
native_tokens,
alias_id,
account_id,
state_index,
state_metadata,
foundry_counter,
unlock_conditions,
features,
immutable_features,
} => {
let output = Output::from(AliasOutput::try_from_dtos(
let output = Output::from(AccountOutput::try_from_dtos(
if let Some(amount) = amount {
OutputBuilderAmountDto::Amount(amount)
} else {
OutputBuilderAmountDto::MinimumStorageDeposit(account.client().get_rent_structure().await?)
},
native_tokens,
&alias_id,
&account_id,
state_index,
state_metadata,
foundry_counter,
Expand Down Expand Up @@ -533,19 +533,19 @@ impl WalletMessageHandler {
})
.await
}
AccountMethod::CreateAliasOutput { params, options } => {
AccountMethod::CreateAccountOutput { params, options } => {
convert_async_panics(|| async {
let transaction = account
.create_alias_output(params, options.map(TransactionOptions::try_from_dto).transpose()?)
.create_account_output(params, options.map(TransactionOptions::try_from_dto).transpose()?)
.await?;
Ok(Response::SentTransaction(TransactionDto::from(&transaction)))
})
.await
}
AccountMethod::DestroyAlias { alias_id, options } => {
AccountMethod::DestroyAccount { account_id, options } => {
convert_async_panics(|| async {
let transaction = account
.burn(alias_id, options.map(TransactionOptions::try_from_dto).transpose()?)
.burn(account_id, options.map(TransactionOptions::try_from_dto).transpose()?)
.await?;
Ok(Response::SentTransaction(TransactionDto::from(&transaction)))
})
Expand Down
5 changes: 3 additions & 2 deletions bindings/core/src/message_interface_old/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub enum Response {
/// [`RetryTransactionUntilIncluded`](crate::wallet::message_interface::AccountMethod::RetryTransactionUntilIncluded)
BlockId(BlockId),
/// Response for
/// [`BuildAliasOutput`](crate::wallet::message_interface::AccountMethod::BuildAliasOutput)
/// [`BuildAccountOutput`](crate::wallet::message_interface::AccountMethod::BuildAccountOutput)
/// [`BuildBasicOutput`](crate::wallet::message_interface::AccountMethod::BuildBasicOutput)
/// [`BuildFoundryOutput`](crate::wallet::message_interface::AccountMethod::BuildFoundryOutput)
/// [`BuildNftOutput`](crate::wallet::message_interface::AccountMethod::BuildNftOutput)
Expand Down Expand Up @@ -112,7 +112,8 @@ pub enum Response {
/// Response for
/// [`ConsolidateOutputs`](crate::wallet::message_interface::AccountMethod::ConsolidateOutputs)
/// [`ClaimOutputs`](crate::wallet::message_interface::AccountMethod::ClaimOutputs)
/// [`CreateAliasOutput`](crate::wallet::message_interface::AccountMethod::CreateAliasOutput)
/// [`CreateAccountOutput`](crate::wallet::message_interface::AccountMethod::CreateAccountOutput)
/// [`SendAmount`](crate::wallet::message_interface::AccountMethod::SendAmount),
/// [`MintNfts`](crate::wallet::message_interface::AccountMethod::MintNfts),
/// [`Send`](crate::wallet::message_interface::AccountMethod::Send),
/// [`SendNativeTokens`](crate::wallet::message_interface::AccountMethod::SendNativeTokens),
Expand Down
10 changes: 5 additions & 5 deletions bindings/core/src/method/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use iota_sdk::{
},
wallet::{
account::{
CreateAliasParams, CreateNativeTokenParams, FilterOptions, MintNftParams, OutputParams, OutputsToClaim,
CreateAccountParams, CreateNativeTokenParams, FilterOptions, MintNftParams, OutputParams, OutputsToClaim,
SyncOptions, TransactionOptionsDto,
},
SendNativeTokensParams, SendNftParams, SendParams,
Expand Down Expand Up @@ -127,7 +127,7 @@ pub enum AccountMethod {
/// Returns all pending transactions of the account
/// Expected response: [`Transactions`](crate::Response::Transactions)
PendingTransactions,
/// A generic `burn()` function that can be used to burn native tokens, nfts, foundries and aliases.
/// A generic `burn()` function that can be used to burn native tokens, nfts, foundries and accounts.
///
/// Note that burning **native tokens** doesn't require the foundry output which minted them, but will not
/// increase the foundries `melted_tokens` field, which makes it impossible to destroy the foundry output.
Expand All @@ -145,10 +145,10 @@ pub enum AccountMethod {
force: bool,
output_consolidation_threshold: Option<usize>,
},
/// Create an alias output.
/// Create an account output.
/// Expected response: [`PreparedTransaction`](crate::Response::PreparedTransaction)
PrepareCreateAliasOutput {
params: Option<CreateAliasParams>,
PrepareCreateAccountOutput {
params: Option<CreateAccountParams>,
options: Option<TransactionOptionsDto>,
},
/// Prepare to create a native token.
Expand Down
28 changes: 14 additions & 14 deletions bindings/core/src/method/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use iota_sdk::{
dto::{OutputDto, TokenSchemeDto},
feature::dto::FeatureDto,
unlock_condition::dto::UnlockConditionDto,
AliasId, FoundryId, NativeToken, NftId, OutputId,
AccountId, FoundryId, NativeToken, NftId, OutputId,
},
payload::{dto::PayloadDto, transaction::TransactionId},
BlockDto, BlockId,
Expand All @@ -25,15 +25,15 @@ use serde::{Deserialize, Serialize};
#[derivative(Debug)]
#[serde(tag = "name", content = "data", rename_all = "camelCase")]
pub enum ClientMethod {
/// Build an AliasOutput.
/// Build an AccountOutput.
/// Expected response: [`Output`](crate::Response::Output)
#[allow(missing_docs)]
#[serde(rename_all = "camelCase")]
BuildAliasOutput {
BuildAccountOutput {
// If not provided, minimum storage deposit will be used
amount: Option<String>,
native_tokens: Option<Vec<NativeToken>>,
alias_id: AliasId,
account_id: AccountId,
state_index: Option<u32>,
state_metadata: Option<String>,
foundry_counter: Option<u32>,
Expand Down Expand Up @@ -206,17 +206,17 @@ pub enum ClientMethod {
/// Query parameters for output requests
query_parameters: Vec<QueryParameter>,
},
/// Fetch alias output IDs
/// Fetch account output IDs
#[serde(rename_all = "camelCase")]
AliasOutputIds {
AccountOutputIds {
/// Query parameters for output requests
query_parameters: Vec<QueryParameter>,
},
/// Fetch alias output ID
/// Fetch account output ID
#[serde(rename_all = "camelCase")]
AliasOutputId {
/// Alias id
alias_id: AliasId,
AccountOutputId {
/// Account id
account_id: AccountId,
},
/// Fetch NFT output IDs
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -338,11 +338,11 @@ pub enum ClientMethod {
/// Human readable part
bech32_hrp: Option<Hrp>,
},
/// Transforms an alias id to a bech32 encoded address
/// Transforms an account id to a bech32 encoded address
#[serde(rename_all = "camelCase")]
AliasIdToBech32 {
/// Alias ID
alias_id: AliasId,
AccountIdToBech32 {
/// Account ID
account_id: AccountId,
/// Human readable part
bech32_hrp: Option<Hrp>,
},
Expand Down
18 changes: 9 additions & 9 deletions bindings/core/src/method/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use derivative::Derivative;
use iota_sdk::types::block::{
address::{Bech32Address, Hrp},
output::{dto::OutputDto, AliasId, NftId, OutputId, RentStructure, TokenScheme},
output::{dto::OutputDto, AccountId, NftId, OutputId, RentStructure, TokenScheme},
payload::transaction::{
dto::{TransactionEssenceDto, TransactionPayloadDto},
TransactionId,
Expand Down Expand Up @@ -34,11 +34,11 @@ pub enum UtilsMethod {
/// Human readable part
bech32_hrp: Hrp,
},
/// Transforms an alias id to a bech32 encoded address
/// Transforms an account id to a bech32 encoded address
#[serde(rename_all = "camelCase")]
AliasIdToBech32 {
/// Alias ID
alias_id: AliasId,
AccountIdToBech32 {
/// Account ID
account_id: AccountId,
/// Human readable part
bech32_hrp: Hrp,
},
Expand Down Expand Up @@ -86,17 +86,17 @@ pub enum UtilsMethod {
/// Transaction Payload
payload: TransactionPayloadDto,
},
/// Computes the alias ID
/// Computes the account ID
#[serde(rename_all = "camelCase")]
ComputeAliasId {
ComputeAccountId {
/// Output ID
output_id: OutputId,
},
/// Computes the Foundry ID
#[serde(rename_all = "camelCase")]
ComputeFoundryId {
/// Alias id
alias_id: AliasId,
account_id: AccountId,
/// Serial number
serial_number: u32,
/// Token scheme kind
Expand All @@ -113,7 +113,7 @@ pub enum UtilsMethod {
/// Computes a tokenId from the aliasId, serial number and token scheme type.
#[serde(rename_all = "camelCase")]
ComputeTokenId {
alias_id: AliasId,
account_id: AccountId,
serial_number: u32,
token_scheme_type: TokenScheme,
},
Expand Down
4 changes: 2 additions & 2 deletions bindings/core/src/method_handler/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ pub(crate) async fn call_account_method_internal(account: &Account, method: Acco
.await?;
Response::PreparedTransaction(PreparedTransactionDataDto::from(&data))
}
AccountMethod::PrepareCreateAliasOutput { params, options } => {
AccountMethod::PrepareCreateAccountOutput { params, options } => {
let data = account
.prepare_create_alias_output(params, options.map(TransactionOptions::try_from_dto).transpose()?)
.prepare_create_account_output(params, options.map(TransactionOptions::try_from_dto).transpose()?)
.await?;
Response::PreparedTransaction(PreparedTransactionDataDto::from(&data))
}
Expand Down
20 changes: 10 additions & 10 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use iota_sdk::{
input::dto::UtxoInputDto,
output::{
dto::{OutputBuilderAmountDto, OutputDto, OutputMetadataDto},
AliasOutput, BasicOutput, FoundryOutput, NftOutput, Output, Rent, RentStructure,
AccountOutput, BasicOutput, FoundryOutput, NftOutput, Output, Rent, RentStructure,
},
payload::Payload,
protocol::dto::ProtocolParametersDto,
Expand Down Expand Up @@ -57,25 +57,25 @@ where
/// Call a client method.
pub(crate) async fn call_client_method_internal(client: &Client, method: ClientMethod) -> Result<Response> {
let response = match method {
ClientMethod::BuildAliasOutput {
ClientMethod::BuildAccountOutput {
amount,
native_tokens,
alias_id,
account_id,
state_index,
state_metadata,
foundry_counter,
unlock_conditions,
features,
immutable_features,
} => {
let output = Output::from(AliasOutput::try_from_dtos(
let output = Output::from(AccountOutput::try_from_dtos(
if let Some(amount) = amount {
OutputBuilderAmountDto::Amount(amount)
} else {
OutputBuilderAmountDto::MinimumStorageDeposit(client.get_rent_structure().await?)
},
native_tokens,
&alias_id,
&account_id,
state_index,
state_metadata.map(prefix_hex::decode).transpose()?,
foundry_counter,
Expand Down Expand Up @@ -247,10 +247,10 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
ClientMethod::BasicOutputIds { query_parameters } => {
Response::OutputIdsResponse(client.basic_output_ids(query_parameters).await?)
}
ClientMethod::AliasOutputIds { query_parameters } => {
Response::OutputIdsResponse(client.alias_output_ids(query_parameters).await?)
ClientMethod::AccountOutputIds { query_parameters } => {
Response::OutputIdsResponse(client.account_output_ids(query_parameters).await?)
}
ClientMethod::AliasOutputId { alias_id } => Response::OutputId(client.alias_output_id(alias_id).await?),
ClientMethod::AccountOutputId { account_id } => Response::OutputId(client.account_output_id(account_id).await?),
ClientMethod::NftOutputIds { query_parameters } => {
Response::OutputIdsResponse(client.nft_output_ids(query_parameters).await?)
}
Expand Down Expand Up @@ -337,8 +337,8 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
ClientMethod::HexToBech32 { hex, bech32_hrp } => {
Response::Bech32Address(client.hex_to_bech32(&hex, bech32_hrp).await?)
}
ClientMethod::AliasIdToBech32 { alias_id, bech32_hrp } => {
Response::Bech32Address(client.alias_id_to_bech32(alias_id, bech32_hrp).await?)
ClientMethod::AccountIdToBech32 { account_id, bech32_hrp } => {
Response::Bech32Address(client.account_id_to_bech32(account_id, bech32_hrp).await?)
}
ClientMethod::NftIdToBech32 { nft_id, bech32_hrp } => {
Response::Bech32Address(client.nft_id_to_bech32(nft_id, bech32_hrp).await?)
Expand Down
Loading

0 comments on commit e0e68e4

Please sign in to comment.