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 3, 2023
1 parent 0229e1a commit 418ae94
Show file tree
Hide file tree
Showing 120 changed files with 2,394 additions and 2,346 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
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,
},
SendAmountParams, SendNativeTokensParams, SendNftParams,
Expand Down Expand Up @@ -131,7 +131,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 @@ -149,10 +149,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 @@ -9,7 +9,7 @@ use iota_sdk::{
types::block::{
address::{Bech32Address, Hrp},
output::{
dto::TokenSchemeDto, feature::dto::FeatureDto, unlock_condition::dto::UnlockConditionDto, AliasId,
dto::TokenSchemeDto, feature::dto::FeatureDto, unlock_condition::dto::UnlockConditionDto, AccountId,
FoundryId, NativeToken, NftId, OutputId,
},
payload::{dto::PayloadDto, transaction::TransactionId},
Expand All @@ -23,15 +23,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 @@ -195,17 +195,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 @@ -327,11 +327,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
20 changes: 10 additions & 10 deletions bindings/core/src/method/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use derivative::Derivative;
use iota_sdk::types::block::{
address::{AliasAddress, Bech32Address, Hrp},
output::{AliasId, NftId, OutputId},
address::{AccountAddress, Bech32Address, Hrp},
output::{AccountId, NftId, OutputId},
payload::transaction::dto::{TransactionEssenceDto, TransactionPayloadDto},
signature::dto::Ed25519SignatureDto,
BlockDto,
Expand All @@ -31,11 +31,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 @@ -83,9 +83,9 @@ 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,
},
Expand All @@ -98,8 +98,8 @@ pub enum UtilsMethod {
/// Computes the Foundry ID
#[serde(rename_all = "camelCase")]
ComputeFoundryId {
/// Alias address
alias_address: AliasAddress,
/// Account address
account_address: AccountAddress,
/// Serial number
serial_number: u32,
/// Token scheme kind
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 @@ -137,9 +137,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, RentStructure,
AccountOutput, BasicOutput, FoundryOutput, NftOutput, Output, 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
12 changes: 6 additions & 6 deletions bindings/core/src/method_handler/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use iota_sdk::{
client::{hex_public_key_to_bech32_address, hex_to_bech32, verify_mnemonic, Client},
types::block::{
address::{dto::AddressDto, Address, ToBech32Ext},
output::{AliasId, FoundryId, NftId},
output::{AccountId, FoundryId, NftId},
payload::{transaction::TransactionEssence, TransactionPayload},
signature::Ed25519Signature,
Block,
Expand All @@ -20,8 +20,8 @@ pub(crate) fn call_utils_method_internal(method: UtilsMethod) -> Result<Response
let response = match method {
UtilsMethod::Bech32ToHex { bech32 } => Response::Bech32ToHex(Client::bech32_to_hex(bech32)?),
UtilsMethod::HexToBech32 { hex, bech32_hrp } => Response::Bech32Address(hex_to_bech32(&hex, bech32_hrp)?),
UtilsMethod::AliasIdToBech32 { alias_id, bech32_hrp } => {
Response::Bech32Address(alias_id.to_bech32(bech32_hrp))
UtilsMethod::AccountIdToBech32 { account_id, bech32_hrp } => {
Response::Bech32Address(account_id.to_bech32(bech32_hrp))
}
UtilsMethod::NftIdToBech32 { nft_id, bech32_hrp } => Response::Bech32Address(nft_id.to_bech32(bech32_hrp)),
UtilsMethod::HexPublicKeyToBech32Address { hex, bech32_hrp } => {
Expand All @@ -43,13 +43,13 @@ pub(crate) fn call_utils_method_internal(method: UtilsMethod) -> Result<Response
let payload = TransactionPayload::try_from_dto_unverified(payload)?;
Response::TransactionId(payload.id())
}
UtilsMethod::ComputeAliasId { output_id } => Response::AliasId(AliasId::from(&output_id)),
UtilsMethod::ComputeAccountId { output_id } => Response::AccountId(AccountId::from(&output_id)),
UtilsMethod::ComputeNftId { output_id } => Response::NftId(NftId::from(&output_id)),
UtilsMethod::ComputeFoundryId {
alias_address,
account_address,
serial_number,
token_scheme_kind,
} => Response::FoundryId(FoundryId::build(&alias_address, serial_number, token_scheme_kind)),
} => Response::FoundryId(FoundryId::build(&account_address, serial_number, token_scheme_kind)),
UtilsMethod::HashTransactionEssence { essence } => Response::TransactionEssenceHash(prefix_hex::encode(
TransactionEssence::try_from_dto_unverified(essence)?.hash(),
)),
Expand Down
16 changes: 8 additions & 8 deletions bindings/core/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use iota_sdk::{
input::dto::UtxoInputDto,
output::{
dto::{OutputDto, OutputMetadataDto},
AliasId, FoundryId, NftId, OutputId,
AccountId, FoundryId, NftId, OutputId,
},
payload::{dto::PayloadDto, transaction::TransactionId},
protocol::dto::ProtocolParametersDto,
Expand Down Expand Up @@ -139,12 +139,12 @@ pub enum Response {
/// - [`GetOutputsIgnoreErrors`](crate::method::ClientMethod::GetOutputsIgnoreErrors)
Outputs(Vec<OutputWithMetadataResponse>),
/// Response for:
/// - [`AliasOutputId`](crate::method::ClientMethod::AliasOutputId)
/// - [`AccountOutputId`](crate::method::ClientMethod::AccountOutputId)
/// - [`FoundryOutputId`](crate::method::ClientMethod::FoundryOutputId)
/// - [`NftOutputId`](crate::method::ClientMethod::NftOutputId)
OutputId(OutputId),
/// Response for:
/// - [`AliasOutputIds`](crate::method::ClientMethod::AliasOutputIds)
/// - [`AccountOutputIds`](crate::method::ClientMethod::AccountOutputIds)
/// - [`BasicOutputIds`](crate::method::ClientMethod::BasicOutputIds)
/// - [`FoundryOutputIds`](crate::method::ClientMethod::FoundryOutputIds)
/// - [`NftOutputIds`](crate::method::ClientMethod::NftOutputIds)
Expand Down Expand Up @@ -179,8 +179,8 @@ pub enum Response {
/// - [`TransactionId`](crate::method::UtilsMethod::TransactionId)
TransactionId(TransactionId),
/// Response for:
/// - [`ComputeAliasId`](crate::method::UtilsMethod::ComputeAliasId)
AliasId(AliasId),
/// - [`ComputeAccountId`](crate::method::UtilsMethod::ComputeAccountId)
AccountId(AccountId),
/// Response for:
/// - [`ComputeNftId`](crate::method::UtilsMethod::ComputeNftId)
NftId(NftId),
Expand All @@ -197,15 +197,15 @@ pub enum Response {

// Responses in client and wallet
/// Response for:
/// - [`BuildAliasOutput`](crate::method::ClientMethod::BuildAliasOutput)
/// - [`BuildAccountOutput`](crate::method::ClientMethod::BuildAccountOutput)
/// - [`BuildBasicOutput`](crate::method::ClientMethod::BuildBasicOutput)
/// - [`BuildFoundryOutput`](crate::method::ClientMethod::BuildFoundryOutput)
/// - [`BuildNftOutput`](crate::method::ClientMethod::BuildNftOutput)
/// - [`GetFoundryOutput`](crate::method::AccountMethod::GetFoundryOutput)
/// - [`PrepareOutput`](crate::method::AccountMethod::PrepareOutput)
Output(OutputDto),
/// Response for:
/// - [`AliasIdToBech32`](crate::method::ClientMethod::AliasIdToBech32)
/// - [`AccountIdToBech32`](crate::method::ClientMethod::AccountIdToBech32)
/// - [`HexPublicKeyToBech32Address`](crate::method::ClientMethod::HexPublicKeyToBech32Address)
/// - [`HexToBech32`](crate::method::ClientMethod::HexToBech32)
/// - [`NftIdToBech32`](crate::method::ClientMethod::NftIdToBech32)
Expand Down Expand Up @@ -288,7 +288,7 @@ pub enum Response {
/// Response for:
/// - [`PrepareBurn`](crate::method::AccountMethod::PrepareBurn),
/// - [`PrepareConsolidateOutputs`](crate::method::AccountMethod::PrepareConsolidateOutputs)
/// - [`PrepareCreateAliasOutput`](crate::method::AccountMethod::PrepareCreateAliasOutput)
/// - [`PrepareCreateAccountOutput`](crate::method::AccountMethod::PrepareCreateAccountOutput)
/// - [`PrepareDecreaseVotingPower`](crate::method::AccountMethod::PrepareDecreaseVotingPower)
/// - [`PrepareIncreaseVotingPower`](crate::method::AccountMethod::PrepareIncreaseVotingPower)
/// - [`PrepareMeltNativeToken`](crate::method::AccountMethod::PrepareMeltNativeToken)
Expand Down
8 changes: 4 additions & 4 deletions cli/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use crate::{
account_history::AccountHistory,
command::account::{
addresses_command, balance_command, burn_native_token_command, burn_nft_command, claim_command,
claimable_outputs_command, consolidate_command, create_alias_outputs_command, create_native_token_command,
decrease_voting_power_command, destroy_alias_command, destroy_foundry_command, faucet_command,
claimable_outputs_command, consolidate_command, create_account_output_command, create_native_token_command,
decrease_voting_power_command, destroy_account_command, destroy_foundry_command, faucet_command,
increase_voting_power_command, melt_native_token_command, mint_native_token, mint_nft_command,
new_address_command, node_info_command, output_command, outputs_command, participation_overview_command,
send_command, send_native_token_command, send_nft_command, stop_participating_command, sync_command,
Expand Down Expand Up @@ -77,7 +77,7 @@ pub async fn account_prompt_internal(account: Account, history: &mut AccountHist
AccountCommand::Claim { output_id } => claim_command(&account, output_id).await,
AccountCommand::ClaimableOutputs => claimable_outputs_command(&account).await,
AccountCommand::Consolidate => consolidate_command(&account).await,
AccountCommand::CreateAliasOutput => create_alias_outputs_command(&account).await,
AccountCommand::CreateAccountOutput => create_account_output_command(&account).await,
AccountCommand::CreateNativeToken {
circulating_supply,
maximum_supply,
Expand All @@ -92,7 +92,7 @@ pub async fn account_prompt_internal(account: Account, history: &mut AccountHist
)
.await
}
AccountCommand::DestroyAlias { alias_id } => destroy_alias_command(&account, alias_id).await,
AccountCommand::DestroyAccount { account_id } => destroy_account_command(&account, account_id).await,
AccountCommand::DestroyFoundry { foundry_id } => destroy_foundry_command(&account, foundry_id).await,
AccountCommand::Exit => {
return Ok(true);
Expand Down
4 changes: 2 additions & 2 deletions cli/src/account_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub(crate) const ACCOUNT_COMPLETION: AccountCompletion = AccountCompletion {
"claim",
"claimable-outputs",
"consolidate",
"create-alias-output",
"create-account-output",
"create-native-token",
"destroy-alias",
"destroy-account",
"destroy-foundry",
"exit",
"faucet",
Expand Down
Loading

0 comments on commit 418ae94

Please sign in to comment.