Skip to content

Commit

Permalink
Merge branch '2.0' into tx-lengths-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M authored Mar 14, 2024
2 parents cf20bb0 + 05cf681 commit e64682b
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 27 deletions.
3 changes: 1 addition & 2 deletions bindings/core/src/method/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ pub enum ClientMethod {
},
/// Return the information of committee members at the given epoch index. If epoch index is not provided, the
/// current committee members are returned.
#[serde(rename_all = "camelCase")]
GetCommittee {
/// The epoch index to query.
epoch_index: Option<EpochIndex>,
epoch: Option<EpochIndex>,
},
/// Get issuance
GetIssuance,
Expand Down
2 changes: 1 addition & 1 deletion bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub(crate) async fn call_client_method_internal(
Response::Validators(client.get_validators(page_size, cursor).await?)
}
ClientMethod::GetValidator { account_id } => Response::Validator(client.get_validator(&account_id).await?),
ClientMethod::GetCommittee { epoch_index } => Response::Committee(client.get_committee(epoch_index).await?),
ClientMethod::GetCommittee { epoch } => Response::Committee(client.get_committee(epoch).await?),
ClientMethod::GetIssuance => Response::Issuance(client.get_issuance().await?),
ClientMethod::PostBlockRaw { block_bytes } => Response::BlockId(
client
Expand Down
6 changes: 3 additions & 3 deletions bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ export class Client {
/**
* Returns the information of committee members at the given epoch index. If epoch index is not provided, the
* current committee members are returned.
* GET /api/core/v3/committee/?epochIndex
* GET /api/core/v3/committee/?epoch
*/
async getCommittee(epochIndex?: EpochIndex): Promise<CommitteeResponse> {
async getCommittee(epoch?: EpochIndex): Promise<CommitteeResponse> {
const response = await this.methodHandler.callMethod({
name: 'getCommittee',
data: {
epochIndex,
epoch,
},
});

Expand Down
14 changes: 8 additions & 6 deletions bindings/nodejs/lib/types/block/output/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { SlotIndex } from '../slot';
import { Type } from 'class-transformer';
import { Transform, Type } from 'class-transformer';
import { Address, AddressDiscriminator } from '../address';
import {
BlockIssuerKey,
Expand All @@ -11,7 +11,7 @@ import {
import { u256, u64 } from '../../utils/type-aliases';
import { EpochIndex } from '../../block/slot';
import { NativeToken } from '../../models/native-token';
import { HexEncodedString } from '../../utils/hex-encoding';
import { HexEncodedString, hexToBigInt } from '../../utils/hex-encoding';

/**
* Printable ASCII characters.
Expand Down Expand Up @@ -147,16 +147,18 @@ class NativeTokenFeature extends Feature {
/**
* Amount of native tokens of the given Token ID.
*/
@Transform((value) => hexToBigInt(value.value))
readonly amount: u256;

/**
* Creates a new `NativeTokenFeature`.
* @param nativeToken The native token stored with the feature.
* @param id The identifier of the native token.
* @param amount The native token amount.
*/
constructor(nativeToken: NativeToken) {
constructor(id: HexEncodedString, amount: u256) {
super(FeatureType.NativeToken);
this.id = nativeToken.id;
this.amount = nativeToken.amount;
this.id = id;
this.amount = amount;
}

/**
Expand Down
1 change: 1 addition & 0 deletions bindings/nodejs/lib/types/block/output/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class BasicOutput extends CommonOutput {

/**
* @param amount The amount of the output.
* @param mana The mana of the output.
* @param unlockConditions The unlock conditions for the output.
*/
constructor(amount: u64, mana: u64, unlockConditions: UnlockCondition[]) {
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/lib/types/client/bridge/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface __GetValidatorMethod__ {
export interface __GetCommitteeMethod__ {
name: 'getCommittee';
data: {
epochIndex?: EpochIndex;
epoch?: EpochIndex;
};
}

Expand Down
6 changes: 3 additions & 3 deletions bindings/python/iota_sdk/client/_node_core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def get_validator(self, account_id: HexStr) -> ValidatorResponse:
# Committee routes.

def get_committee(
self, epoch_index: Optional[EpochIndex] = None) -> CommitteeResponse:
self, epoch: Optional[EpochIndex] = None) -> CommitteeResponse:
"""Returns the information of committee members at the given epoch index. If epoch index is not provided, the
current committee members are returned.
GET /api/core/v3/committee/?epochIndex
GET /api/core/v3/committee/?epoch
"""
return CommitteeResponse.from_dict(self._call_method('getCommittee', {
'epochIndex': epoch_index
'epoch': epoch
}))

# Block routes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ pub enum TransactionBuilderError {
required: u64,
},
/// Insufficient mana provided.
#[error("insufficient mana: found {found}, required {required}")]
#[error(
"insufficient mana: found {found}, required {required}, slots remaining until enough mana {slots_remaining}"
)]
InsufficientMana {
/// The amount found.
found: u64,
Expand Down
20 changes: 13 additions & 7 deletions sdk/src/client/api/wait_for_tx_acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ impl Client {
.unwrap_or(DEFAULT_WAIT_FOR_TX_ACCEPTANCE_INTERVAL);

for _ in 0..max_attempts.unwrap_or(DEFAULT_WAIT_FOR_TX_ACCEPTANCE_MAX_ATTEMPTS) {
let transaction_metadata = self.get_transaction_metadata(transaction_id).await?;

match transaction_metadata.transaction_state {
TransactionState::Accepted | TransactionState::Committed | TransactionState::Finalized => {
return Ok(());
match self.get_transaction_metadata(transaction_id).await {
Ok(transaction_metadata) => {
match transaction_metadata.transaction_state {
TransactionState::Accepted | TransactionState::Committed | TransactionState::Finalized => {
return Ok(());
}
TransactionState::Failed => {
return Err(ClientError::TransactionAcceptance(transaction_id.to_string()));
}
TransactionState::Pending => {} // Just need to wait longer
};
}
TransactionState::Failed => return Err(ClientError::TransactionAcceptance(transaction_id.to_string())),
TransactionState::Pending => {} // Just need to wait longer
Err(ClientError::Node(crate::client::node_api::error::Error::NotFound(_))) => {}
Err(e) => return Err(e),
};

#[cfg(target_family = "wasm")]
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/client/node_api/core/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ impl Client {

/// Returns the information of committee members at the given epoch index. If epoch index is not provided, the
/// current committee members are returned.
/// GET /api/core/v3/committee/?epochIndex
/// GET /api/core/v3/committee/?epoch
pub async fn get_committee(
&self,
epoch_index: impl Into<Option<EpochIndex>> + Send,
epoch: impl Into<Option<EpochIndex>> + Send,
) -> Result<CommitteeResponse, ClientError> {
const PATH: &str = "api/core/v3/committee";
let query = query_tuples_to_query_string([epoch_index.into().map(|i| ("epochIndex", i.to_string()))]);
let query = query_tuples_to_query_string([epoch.into().map(|i| ("epoch", i.to_string()))]);

self.get_request(PATH, query.as_deref(), false).await
}
Expand Down

0 comments on commit e64682b

Please sign in to comment.