Skip to content

Commit

Permalink
Merge branch '2.0' into feat/output-storage-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DaughterOfMars authored Jan 12, 2024
2 parents 42dd18f + 68e8ced commit 2e26ed1
Show file tree
Hide file tree
Showing 40 changed files with 3,621 additions and 2,845 deletions.
21 changes: 21 additions & 0 deletions bindings/core/src/method/secret_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ pub enum SecretManagerMethod {
#[derivative(Debug(format_with = "OmittedDebug::omitted_fmt"))]
mnemonic: String,
},
/// Set the stronghold password.
/// Expected response: [`Ok`](crate::Response::Ok)
#[cfg(feature = "stronghold")]
#[cfg_attr(docsrs, doc(cfg(feature = "stronghold")))]
SetStrongholdPassword {
#[derivative(Debug(format_with = "OmittedDebug::omitted_fmt"))]
password: String,
},
/// Change the stronghold password.
/// Expected response: [`Ok`](crate::Response::Ok)
#[cfg(feature = "stronghold")]
#[cfg_attr(docsrs, doc(cfg(feature = "stronghold")))]
ChangeStrongholdPassword {
#[derivative(Debug(format_with = "OmittedDebug::omitted_fmt"))]
password: String,
},
/// Clear the stronghold password.
/// Expected response: [`Ok`](crate::Response::Ok)
#[cfg(feature = "stronghold")]
#[cfg_attr(docsrs, doc(cfg(feature = "stronghold")))]
ClearStrongholdPassword,
}

#[cfg(test)]
Expand Down
36 changes: 36 additions & 0 deletions bindings/core/src/method_handler/secret_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,42 @@ where
return Err(iota_sdk::client::Error::SecretManagerMismatch.into());
}
}
#[cfg(feature = "stronghold")]
SecretManagerMethod::SetStrongholdPassword { password } => {
let stronghold = if let Some(secret_manager) = secret_manager.downcast::<StrongholdSecretManager>() {
secret_manager
} else if let Some(SecretManager::Stronghold(secret_manager)) = secret_manager.downcast::<SecretManager>() {
secret_manager
} else {
return Err(iota_sdk::client::Error::SecretManagerMismatch.into());
};
stronghold.set_password(password).await?;
Response::Ok
}
#[cfg(feature = "stronghold")]
SecretManagerMethod::ChangeStrongholdPassword { password } => {
let stronghold = if let Some(secret_manager) = secret_manager.downcast::<StrongholdSecretManager>() {
secret_manager
} else if let Some(SecretManager::Stronghold(secret_manager)) = secret_manager.downcast::<SecretManager>() {
secret_manager
} else {
return Err(iota_sdk::client::Error::SecretManagerMismatch.into());
};
stronghold.change_password(password).await?;
Response::Ok
}
#[cfg(feature = "stronghold")]
SecretManagerMethod::ClearStrongholdPassword => {
let stronghold = if let Some(secret_manager) = secret_manager.downcast::<StrongholdSecretManager>() {
secret_manager
} else if let Some(SecretManager::Stronghold(secret_manager)) = secret_manager.downcast::<SecretManager>() {
secret_manager
} else {
return Err(iota_sdk::client::Error::SecretManagerMismatch.into());
};
stronghold.clear_key().await;
Response::Ok
}
};
Ok(response)
}
29 changes: 29 additions & 0 deletions bindings/nodejs/lib/secret_manager/secret-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,33 @@ export class SecretManager {

return JSON.parse(response).payload;
}

/**
* Set the Stronghold password.
*/
async setStrongholdPassword(password: string): Promise<void> {
await this.methodHandler.callMethod({
name: 'setStrongholdPassword',
data: { password },
});
}

/**
* Change the Stronghold password.
*/
async changeStrongholdPassword(password: string): Promise<void> {
await this.methodHandler.callMethod({
name: 'changeStrongholdPassword',
data: { password },
});
}

/**
* Clear the Stronghold password.
*/
async clearStrongholdPassword(): Promise<void> {
await this.methodHandler.callMethod({
name: 'clearStrongholdPassword',
});
}
}
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/types/block/output/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ class BlockIssuerFeature extends Feature {
@Type(() => BlockIssuerKey, {
discriminator: BlockIssuerKeyDiscriminator,
})
readonly blockIssuerKeys: Set<BlockIssuerKey>;
readonly blockIssuerKeys: BlockIssuerKey[];

constructor(expirySlot: SlotIndex, blockIssuerKeys: Set<BlockIssuerKey>) {
constructor(expirySlot: SlotIndex, blockIssuerKeys: BlockIssuerKey[]) {
super(FeatureType.BlockIssuer);
this.expirySlot = expirySlot;
this.blockIssuerKeys = blockIssuerKeys;
Expand Down
8 changes: 7 additions & 1 deletion bindings/nodejs/lib/types/secret_manager/bridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import type {
__SignatureUnlockMethod__,
__SignEd25519Method__,
__SignSecp256k1EcdsaMethod__,
__SetStrongholdPasswordMethod__,
__ChangeStrongholdPasswordMethod__,
__ClearStrongholdPasswordMethod__,
} from './secret-manager';

export type __SecretManagerMethods__ =
Expand All @@ -19,4 +22,7 @@ export type __SecretManagerMethods__ =
| __SignatureUnlockMethod__
| __StoreMnemonicMethod__
| __SignEd25519Method__
| __SignSecp256k1EcdsaMethod__;
| __SignSecp256k1EcdsaMethod__
| __SetStrongholdPasswordMethod__
| __ChangeStrongholdPasswordMethod__
| __ClearStrongholdPasswordMethod__;
14 changes: 14 additions & 0 deletions bindings/nodejs/lib/types/secret_manager/bridge/secret-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,17 @@ export interface __SignSecp256k1EcdsaMethod__ {
export interface __GetLedgerNanoStatusMethod__ {
name: 'getLedgerNanoStatus';
}

export interface __SetStrongholdPasswordMethod__ {
name: 'setStrongholdPassword';
data: { password: string };
}

export interface __ChangeStrongholdPasswordMethod__ {
name: 'changeStrongholdPassword';
data: { password: string };
}

export interface __ClearStrongholdPasswordMethod__ {
name: 'clearStrongholdPassword';
}
4 changes: 3 additions & 1 deletion bindings/python/iota_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

from .external import *

from .client.client import Client, NodeIndexerAPI, ClientError
from .common import custom_encoder
from .client.client import Client, NodeIndexerAPI
from .client.common import ClientError
from .client._high_level_api import GenerateAddressesOptions, GenerateAddressOptions
from .utils import Utils
from .wallet.wallet import Wallet, WalletOptions
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/client/_node_core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def post_block(self, block: Block) -> HexStr:
The block id of the posted block.
"""
return self._call_method('postBlock', {
'block': block.to_dict()
'block': block
})

def get_block(self, block_id: HexStr) -> Block:
Expand Down
28 changes: 7 additions & 21 deletions bindings/python/iota_sdk/client/_node_indexer_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,8 @@ def output_ids(
The corresponding output IDs of the outputs.
"""

query_parameters_camelized = query_parameters.to_dict()

response = self._call_method('outputIds', {
'queryParameters': query_parameters_camelized,
'queryParameters': query_parameters,
})
return OutputIdsResponse(response)

Expand All @@ -276,10 +274,8 @@ def basic_output_ids(
The corresponding output IDs of the basic outputs.
"""

query_parameters_camelized = query_parameters.to_dict()

response = self._call_method('basicOutputIds', {
'queryParameters': query_parameters_camelized,
'queryParameters': query_parameters,
})
return OutputIdsResponse(response)

Expand All @@ -291,10 +287,8 @@ def account_output_ids(
The corresponding output IDs of the account outputs.
"""

query_parameters_camelized = query_parameters.to_dict()

response = self._call_method('accountOutputIds', {
'queryParameters': query_parameters_camelized,
'queryParameters': query_parameters,
})
return OutputIdsResponse(response)

Expand All @@ -316,10 +310,8 @@ def anchor_output_ids(
The corresponding output IDs of the anchor outputs.
"""

query_parameters_camelized = query_parameters.to_dict()

response = self._call_method('anchorOutputIds', {
'queryParameters': query_parameters_camelized,
'queryParameters': query_parameters,
})
return OutputIdsResponse(response)

Expand All @@ -341,10 +333,8 @@ def delegation_output_ids(
The corresponding output IDs of the delegation outputs.
"""

query_parameters_camelized = query_parameters.to_dict()

response = self._call_method('delegationOutputIds', {
'queryParameters': query_parameters_camelized,
'queryParameters': query_parameters,
})
return OutputIdsResponse(response)

Expand All @@ -366,10 +356,8 @@ def foundry_output_ids(
The corresponding output IDs of the foundry outputs.
"""

query_parameters_camelized = query_parameters.to_dict()

response = self._call_method('foundryOutputIds', {
'queryParameters': query_parameters_camelized,
'queryParameters': query_parameters,
})
return OutputIdsResponse(response)

Expand All @@ -391,10 +379,8 @@ def nft_output_ids(
The corresponding output IDs of the NFT outputs.
"""

query_parameters_camelized = query_parameters.to_dict()

response = self._call_method('nftOutputIds', {
'queryParameters': query_parameters_camelized,
'queryParameters': query_parameters,
})
return OutputIdsResponse(response)

Expand Down
Loading

0 comments on commit 2e26ed1

Please sign in to comment.