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 55 commits
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
6 changes: 1 addition & 5 deletions bindings/core/src/method/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use iota_sdk::{
address::{Bech32Address, Hrp},
output::{
dto::OutputDto, feature::Feature, unlock_condition::dto::UnlockConditionDto, AccountId, AnchorId,
DelegationId, FoundryId, NativeToken, NftId, OutputId, TokenScheme,
DelegationId, FoundryId, NftId, OutputId, TokenScheme,
},
payload::{dto::PayloadDto, signed_transaction::TransactionId},
BlockId, IssuerId, SignedBlockDto,
Expand All @@ -43,7 +43,6 @@ pub enum ClientMethod {
// TODO: Determine if `default` is wanted here
#[serde(default, with = "string")]
mana: u64,
native_tokens: Option<Vec<NativeToken>>,
account_id: AccountId,
foundry_counter: Option<u32>,
unlock_conditions: Vec<UnlockConditionDto>,
Expand All @@ -61,7 +60,6 @@ pub enum ClientMethod {
// TODO: Determine if `default` is wanted here
#[serde(default, with = "string")]
mana: u64,
native_tokens: Option<Vec<NativeToken>>,
unlock_conditions: Vec<UnlockConditionDto>,
features: Option<Vec<Feature>>,
},
Expand All @@ -73,7 +71,6 @@ pub enum ClientMethod {
// If not provided, minimum amount will be used
#[serde(default, with = "option_string")]
amount: Option<u64>,
native_tokens: Option<Vec<NativeToken>>,
serial_number: u32,
token_scheme: TokenScheme,
unlock_conditions: Vec<UnlockConditionDto>,
Expand All @@ -91,7 +88,6 @@ pub enum ClientMethod {
// TODO: Determine if `default` is wanted here
#[serde(default, with = "string")]
mana: u64,
native_tokens: Option<Vec<NativeToken>>,
nft_id: NftId,
unlock_conditions: Vec<UnlockConditionDto>,
features: Option<Vec<Feature>>,
Expand Down
4 changes: 2 additions & 2 deletions bindings/core/src/method/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use iota_sdk::{
},
wallet::{
ClientOptions, ConsolidationParams, CreateAccountParams, CreateNativeTokenParams, FilterOptions, MintNftParams,
OutputParams, OutputsToClaim, SendNativeTokensParams, SendNftParams, SendParams, SyncOptions,
OutputParams, OutputsToClaim, SendNativeTokenParams, SendNftParams, SendParams, SyncOptions,
TransactionOptions,
},
U256,
Expand Down Expand Up @@ -295,7 +295,7 @@ pub enum WalletMethod {
/// Prepare to send native tokens.
/// Expected response: [`PreparedTransaction`](crate::Response::PreparedTransaction)
PrepareSendNativeTokens {
params: Vec<SendNativeTokensParams>,
params: Vec<SendNativeTokenParams>,
options: Option<TransactionOptions>,
},
/// Prepare to Send nft.
Expand Down
8 changes: 0 additions & 8 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
ClientMethod::BuildAccountOutput {
amount,
mana,
native_tokens,
account_id,
foundry_counter,
unlock_conditions,
Expand All @@ -73,7 +72,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
OutputBuilderAmount::MinimumAmount(client.get_storage_score_parameters().await?)
},
mana,
native_tokens,
&account_id,
foundry_counter,
unlock_conditions,
Expand All @@ -86,7 +84,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
ClientMethod::BuildBasicOutput {
amount,
mana,
native_tokens,
unlock_conditions,
features,
} => {
Expand All @@ -97,7 +94,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
OutputBuilderAmount::MinimumAmount(client.get_storage_score_parameters().await?)
},
mana,
native_tokens,
unlock_conditions,
features,
)?);
Expand All @@ -106,7 +102,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
}
ClientMethod::BuildFoundryOutput {
amount,
native_tokens,
serial_number,
token_scheme,
unlock_conditions,
Expand All @@ -119,7 +114,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
} else {
OutputBuilderAmount::MinimumAmount(client.get_storage_score_parameters().await?)
},
native_tokens,
serial_number,
token_scheme,
unlock_conditions,
Expand All @@ -132,7 +126,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
ClientMethod::BuildNftOutput {
amount,
mana,
native_tokens,
nft_id,
unlock_conditions,
features,
Expand All @@ -145,7 +138,6 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
OutputBuilderAmount::MinimumAmount(client.get_storage_score_parameters().await?)
},
mana,
native_tokens,
&nft_id,
unlock_conditions,
features,
Expand Down
10 changes: 5 additions & 5 deletions bindings/nodejs/examples/how_tos/native_tokens/send.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { SendNativeTokensParams } from '@iota/sdk';
import { SendNativeTokenParams } from '@iota/sdk';

import { getUnlockedWallet } from '../../wallet/common';

// The native token amount to send.
const SEND_NATIVE_TOKEN_AMOUNT = BigInt(10);
// The address to send the tokens to
// The address to send the token to
const RECV_ADDRESS =
'rms1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluaw60xu';

// In this example we will send native tokens.
// In this example we will send a native token.
//
// Make sure that `STRONGHOLD_SNAPSHOT_PATH` and `WALLET_DB_PATH` already exist by
// running the `how_tos/accounts_and_addresses/create-wallet` example!
Expand All @@ -32,10 +32,10 @@ async function run() {
)?.tokenId;

if (tokenId != null) {
const outputs: SendNativeTokensParams[] = [
const outputs: SendNativeTokenParams[] = [
{
address: RECV_ADDRESS,
nativeTokens: [[tokenId, SEND_NATIVE_TOKEN_AMOUNT]],
nativeToken: [tokenId, SEND_NATIVE_TOKEN_AMOUNT],
},
];

Expand Down
8 changes: 4 additions & 4 deletions bindings/nodejs/lib/types/wallet/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export interface SendParams {
expiration?: SlotIndex;
}

/** Address with native tokens */
export interface SendNativeTokensParams {
/** Address with native token */
export interface SendNativeTokenParams {
/** The Bech32 address. */
address: Bech32Address;
/** The Native Tokens to send. */
nativeTokens: [TokenId, u256][];
/** The Native Token to send. */
nativeToken: [TokenId, u256];
/**
* Bech32 encoded address, to which the storage deposit will be returned.
* Default will use the address of the wallet.
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 @@ -3,7 +3,7 @@

import type {
SendParams,
SendNativeTokensParams,
SendNativeTokenParams,
SendNftParams,
GenerateAddressOptions,
} from '../address';
Expand Down Expand Up @@ -258,7 +258,7 @@ export type __SendWithParamsMethod__ = {
export type __PrepareSendNativeTokensMethod__ = {
name: 'prepareSendNativeTokens';
data: {
params: SendNativeTokensParams[];
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
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/types/wallet/output-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export interface OutputParams {

/** Assets to include in the output. */
export interface Assets {
/** Native Token assets to include. */
nativeTokens?: INativeToken[];
/** The NFT to include. */
nftId?: HexEncodedString;
}
Expand All @@ -40,6 +38,8 @@ export interface Features {
sender?: string;
/** An Issuer feature to include. */
issuer?: string;
/** Native Token to include. */
nativeToken?: INativeToken;
}

/** Time unlocks to include in the output. */
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
24 changes: 1 addition & 23 deletions bindings/nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bindings/nodejs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2201,9 +2201,9 @@ fs.realpath@^1.0.0:
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@^2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
version "2.3.2"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

fstream@^1.0.0, fstream@~1.0.10:
version "1.0.12"
Expand Down
8 changes: 4 additions & 4 deletions bindings/python/examples/how_tos/native_tokens/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dotenv import load_dotenv

from iota_sdk import SendNativeTokensParams, Wallet
from iota_sdk import SendNativeTokenParams, Wallet

load_dotenv()

Expand All @@ -24,12 +24,12 @@

wallet.set_stronghold_password(os.environ["STRONGHOLD_PASSWORD"])

outputs = [SendNativeTokensParams(
outputs = [SendNativeTokenParams(
"rms1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluaw60xu",
[(
(
token.token_id,
hex(10)
)],
),
)]

transaction = account.send_native_tokens(outputs, None)
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/output_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
class Assets():
"""Assets for OutputParams.
"""
native_tokens: Optional[List[NativeToken]] = None
nft_id: Optional[HexStr] = None


Expand All @@ -28,6 +27,7 @@ class Features():
metadata: Optional[HexStr] = None
issuer: Optional[str] = None
sender: Optional[str] = None
native_token: Optional[NativeToken] = None


@json
Expand Down
12 changes: 6 additions & 6 deletions bindings/python/iota_sdk/types/send_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ class SendParams():

@json
@dataclass
class SendNativeTokensParams():
"""Parameters for sending native tokens
class SendNativeTokenParams():
"""Parameters for sending a native token

Attributes:
address: The address to send to.
native_tokens: The native tokens to send.
return_address: The address to return the native tokens to if not claimed.
expiration: The expiration timestamp until native tokens can be claimed.
native_token: The native token to send.
return_address: The address to return the native token to if not claimed.
expiration: The expiration timestamp until the native token can be claimed.
"""
address: str
native_tokens: List[NativeToken]
native_token: NativeToken
return_address: Optional[str] = None
expiration: Optional[int] = None

Expand Down
Loading
Loading