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

Native token refactoring #1364

Merged
merged 63 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
ce83b85
Add NativeTokenFeature
thibault-martinez Oct 1, 2023
2ae1ac1
Remove NativeTokens from Account
thibault-martinez Oct 1, 2023
2230942
Remove Native Token from NFT
thibault-martinez Oct 1, 2023
374d5a2
Fix warnings
thibault-martinez Oct 1, 2023
3e34c24
Add rand_native_token_feature
thibault-martinez Oct 1, 2023
4c3e879
Add to ALLOWED_FEATURES
thibault-martinez Oct 1, 2023
c3df687
Remove native tokens from Basic/Foundry
thibault-martinez Oct 1, 2023
67cb9e9
Fix semantic validation
thibault-martinez Oct 1, 2023
f93094b
Fix balance
thibault-martinez Oct 1, 2023
3e9aca1
Fix prepare_output
thibault-martinez Oct 1, 2023
387d91d
Change feature order
thibault-martinez Oct 2, 2023
283cd49
Some fixes
thibault-martinez Oct 2, 2023
4e3db0a
Some more changes
thibault-martinez Oct 2, 2023
2aaf0a5
Lift transaction max native token count
thibault-martinez Oct 2, 2023
3666fdd
Some bindings changes
thibault-martinez Oct 2, 2023
1e68d87
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 2, 2023
d094379
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 4, 2023
8e196b5
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 5, 2023
16ca78e
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 16, 2023
cc54f8a
Fix
thibault-martinez Oct 16, 2023
7bba80d
Some fixes
thibault-martinez Oct 16, 2023
faf1d3f
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 19, 2023
1c7e242
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 20, 2023
5411ddd
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 24, 2023
9d5ebd3
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 26, 2023
6e2356f
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 30, 2023
7b239dd
Merge branch '2.0' into native-token-feature
thibault-martinez Oct 30, 2023
f458797
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 16, 2023
0b24cec
Some fixes
thibault-martinez Nov 16, 2023
c1e988c
Fix balance
thibault-martinez Nov 16, 2023
b896a6c
Some more fixes
thibault-martinez Nov 16, 2023
0d454be
Comment ISA not supporting multiple remainders
thibault-martinez Nov 16, 2023
9d88e53
Comment unsupported native tokens in output consolidation
thibault-martinez Nov 16, 2023
7665cd6
Comment unsupported native tokens in output claiming
thibault-martinez Nov 16, 2023
fbd2fe3
More fixes
thibault-martinez Nov 16, 2023
ef44552
Fix CLI
thibault-martinez Nov 16, 2023
7b9298a
More changes - help :(
thibault-martinez Nov 16, 2023
fcbf7c9
Cleanup
thibault-martinez Nov 16, 2023
2e8db57
Fix bindings core
thibault-martinez Nov 16, 2023
edf76b0
Fix more tests
thibault-martinez Nov 16, 2023
b7ba5eb
moar
thibault-martinez Nov 16, 2023
3c47984
Disable some test files
thibault-martinez Nov 16, 2023
a8c9110
Fix last tests
thibault-martinez Nov 16, 2023
3dc57ea
Revert failed merged
thibault-martinez Nov 16, 2023
16b3971
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 17, 2023
3d568c7
Remove StorageScore for NativeToken
thibault-martinez Nov 17, 2023
775565e
Revert rename
thibault-martinez Nov 17, 2023
96d4ddd
Bindings nits
thibault-martinez Nov 17, 2023
c713100
Add NativeTokenFeatureDto
thibault-martinez Nov 17, 2023
8ca7c91
Semantic nits
thibault-martinez Nov 17, 2023
d837504
Remove print
thibault-martinez Nov 17, 2023
6614eb3
Remove TODOs
thibault-martinez Nov 17, 2023
21fc7f3
Nit
thibault-martinez Nov 17, 2023
7cef116
Change Assets in bindings
thibault-martinez Nov 17, 2023
afdc589
#[serde(rename = "id")]
thibault-martinez Nov 17, 2023
03b31df
Update sdk/src/wallet/operations/transaction/prepare_transaction.rs
thibault-martinez Nov 17, 2023
2ceae42
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 17, 2023
bccbee2
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 17, 2023
8b2fa23
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 17, 2023
abdd9bc
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 17, 2023
ad96d8e
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 20, 2023
1581b6f
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 20, 2023
33e7151
Merge branch '2.0' into native-token-feature
thibault-martinez Nov 20, 2023
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
2 changes: 1 addition & 1 deletion bindings/core/src/method_handler/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pub(crate) async fn call_wallet_method_internal(wallet: &Wallet, method: WalletM
Response::PreparedTransaction(PreparedTransactionDataDto::from(&data))
}
WalletMethod::PrepareSendNativeTokens { params, options } => {
let data = wallet.prepare_send_native_token(params.clone(), options).await?;
let data = wallet.prepare_send_native_tokens(params.clone(), options).await?;
Response::PreparedTransaction(PreparedTransactionDataDto::from(&data))
}
WalletMethod::PrepareSendNft { params, options } => {
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/examples/how_tos/native_tokens/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function run() {
}
console.log(`Balance before sending: ${token.available}`);

const transaction = await wallet.sendNativeToken(outputs);
const transaction = await wallet.sendNativeTokens(outputs);

console.log(`Transaction sent: ${transaction.transactionId}`);

Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/types/wallet/bridge/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ export type __SendWithParamsMethod__ = {
};
};

export type __PrepareSendNativeTokenMethod__ = {
name: 'prepareSendNativeToken';
export type __PrepareSendNativeTokensMethod__ = {
name: 'prepareSendNativeTokens';
data: {
params: SendNativeTokenParams[];
options?: TransactionOptions;
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 @@ -9,7 +9,7 @@ import type {
} from '../../client';
import type {
SendParams,
SendNativeTokensParams,
SendNativeTokenParams,
Thoralf-M marked this conversation as resolved.
Show resolved Hide resolved
SendNftParams,
} from '../address';
import type { OutputParams } from '../output-params';
Expand Down Expand Up @@ -337,7 +337,7 @@ export type __SendWithParamsMethod__ = {
export type __PrepareSendNativeTokensMethod__ = {
name: 'prepareSendNativeTokens';
data: {
params: SendNativeTokensParams[];
params: SendNativeTokenParams[];
options?: TransactionOptions;
};
};
Expand Down
6 changes: 3 additions & 3 deletions bindings/nodejs/lib/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Balance,
SyncOptions,
SendParams,
SendNativeTokensParams,
SendNativeTokenParams,
SendNftParams,
AccountOutputParams,
FilterOptions,
Expand Down Expand Up @@ -1318,7 +1318,7 @@ export class Wallet {
* @returns The transaction.
*/
async sendNativeTokens(
params: SendNativeTokensParams[],
params: SendNativeTokenParams[],
transactionOptions?: TransactionOptions,
): Promise<TransactionWithMetadata> {
return (
Expand All @@ -1335,7 +1335,7 @@ export class Wallet {
* @returns The prepared transaction.
*/
async prepareSendNativeTokens(
params: SendNativeTokensParams[],
params: SendNativeTokenParams[],
transactionOptions?: TransactionOptions,
): Promise<PreparedTransaction> {
const response = await this.methodHandler.callMethod({
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/examples/how_tos/native_tokens/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
),
)]

transaction = account.send_native_token(outputs, None)
transaction = account.send_native_tokens(outputs, None)
print(f'Transaction sent: {transaction.transaction_id}')

# Wait for transaction to get included
Expand Down
6 changes: 3 additions & 3 deletions bindings/python/iota_sdk/wallet/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,13 @@ def send_with_params(
}
))

def send_native_token(
def send_native_tokens(
self, params: List[SendNativeTokenParams], options: Optional[TransactionOptions] = None) -> TransactionWithMetadata:
"""Send native tokens.
"""
return self.prepare_send_native_token(params, options).send()
return self.prepare_send_native_tokens(params, options).send()

def prepare_send_native_token(
def prepare_send_native_tokens(
self,
params: List[SendNativeTokenParams],
options: Optional[TransactionOptions] = None) -> PreparedTransaction:
Expand Down
4 changes: 2 additions & 2 deletions cli/src/wallet_cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub enum WalletCommand {
#[arg(long, default_value_t = false)]
allow_micro_amount: bool,
},
/// Send native tokens.
/// Send a native token.
/// This will create an output with an expiration and storage deposit return unlock condition.
SendNativeToken {
/// Address to send the native tokens to, e.g. rms1qztwng6cty8cfm42nzvq099ev7udhrnk0rw8jt8vttf9kpqnxhpsx869vr3.
Expand Down Expand Up @@ -753,7 +753,7 @@ pub async fn send_native_token_command(
U256::from_dec_str(&amount).map_err(|e| Error::Miscellaneous(e.to_string()))?,
),
)?];
wallet.send_native_token(outputs, None).await?
wallet.send_native_tokens(outputs, None).await?
};

println_log_info!(
Expand Down
2 changes: 1 addition & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ path = "examples/how_tos/native_tokens/mint.rs"
required-features = ["rocksdb", "stronghold"]

[[example]]
name = "send_native_token"
name = "send_native_tokens"
path = "examples/how_tos/native_tokens/send.rs"
required-features = ["rocksdb", "stronghold"]

Expand Down
4 changes: 2 additions & 2 deletions sdk/examples/how_tos/native_tokens/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//!
//! Rename `.env.example` to `.env` first, then run the command:
//! ```sh
//! cargo run --release --all-features --example send_native_token
//! cargo run --release --all-features --example send_native_tokens
//! ```

use iota_sdk::{
Expand Down Expand Up @@ -63,7 +63,7 @@ async fn main() -> Result<()> {
(*token_id, U256::from(SEND_NATIVE_TOKEN_AMOUNT)),
)?];

let transaction = wallet.send_native_token(outputs, None).await?;
let transaction = wallet.send_native_tokens(outputs, None).await?;
println!("Transaction sent: {}", transaction.transaction_id);

// Wait for transaction to get included
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub use self::{
mint_nfts::MintNftParams,
},
send::SendParams,
send_native_token::SendNativeTokenParams,
send_native_tokens::SendNativeTokenParams,
send_nft::SendNftParams,
},
prepare_output::{Assets, Features, OutputParams, ReturnStrategy, StorageDeposit, Unlocks},
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/transaction/high_level/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pub(crate) mod burning_melting;
pub(crate) mod create_account;
pub(crate) mod minting;
pub(crate) mod send;
pub(crate) mod send_native_token;
pub(crate) mod send_native_tokens;
pub(crate) mod send_nft;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
},
};

/// Params for `send_native_token()`
/// Params for `send_native_tokens()`
#[derive(Debug, Clone, Serialize, Deserialize, Getters)]
#[serde(rename_all = "camelCase")]
pub struct SendNativeTokenParams {
Expand Down Expand Up @@ -93,13 +93,13 @@ where
/// ..Default::default()
/// }];
///
/// let tx = account.send_native_token(params, None).await?;
/// let tx = account.send_native_tokens(params, None).await?;
/// println!("Transaction created: {}", tx.transaction_id);
/// if let Some(block_id) = tx.block_id {
/// println!("Block sent: {}", block_id);
/// }
/// ```
pub async fn send_native_token<I: IntoIterator<Item = SendNativeTokenParams> + Send>(
pub async fn send_native_tokens<I: IntoIterator<Item = SendNativeTokenParams> + Send>(
&self,
params: I,
options: impl Into<Option<TransactionOptions>> + Send,
Expand All @@ -108,22 +108,22 @@ where
I::IntoIter: Send,
{
let options = options.into();
let prepared_transaction = self.prepare_send_native_token(params, options.clone()).await?;
let prepared_transaction = self.prepare_send_native_tokens(params, options.clone()).await?;

self.sign_and_submit_transaction(prepared_transaction, options).await
}

/// Prepares the transaction for
/// [Account::send_native_token()](crate::wallet::Account::send_native_token).
pub async fn prepare_send_native_token<I: IntoIterator<Item = SendNativeTokenParams> + Send>(
/// [Account::send_native_tokens()](crate::wallet::Account::send_native_tokens).
pub async fn prepare_send_native_tokens<I: IntoIterator<Item = SendNativeTokenParams> + Send>(
&self,
params: I,
options: impl Into<Option<TransactionOptions>> + Send,
) -> crate::wallet::Result<PreparedTransactionData>
where
I::IntoIter: Send,
{
log::debug!("[TRANSACTION] prepare_send_native_token");
log::debug!("[TRANSACTION] prepare_send_native_tokens");
let storage_score_params = self.client().get_storage_score_parameters().await?;

let wallet_address = self.address().await;
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/wallet/claim_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ async fn claim_2_native_tokens() -> Result<()> {
wallet_1.sync(None).await?;

let tx = wallet_1
.send_native_token(
.send_native_tokens(
[
SendNativeTokenParams::new(wallet_0.address().await, (create_tx_0.token_id, native_token_amount))?,
SendNativeTokenParams::new(wallet_0.address().await, (create_tx_1.token_id, native_token_amount))?,
Expand Down
Loading