Skip to content

Commit

Permalink
Merge branch 'develop' into tooling-dashboard/style-balance-box
Browse files Browse the repository at this point in the history
  • Loading branch information
evavirseda authored Oct 29, 2024
2 parents e9e11d5 + f5b64c5 commit ca3ae52
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 82 deletions.
73 changes: 2 additions & 71 deletions crates/iota/src/keytool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use std::{
fmt::{Debug, Display, Formatter},
fs,
path::{Path, PathBuf},
path::PathBuf,
sync::Arc,
};

Expand Down Expand Up @@ -150,12 +149,6 @@ pub enum KeyToolCommand {
#[clap(long, short = 's')]
sort_by_alias: bool,
},
/// This reads the content at the provided file path. The accepted format
/// is a Bech32 encoded [enum IotaKeyPair] or `type AuthorityKeyPair`
/// (Base64 encoded `privkey`). This prints out the account keypair as
/// Base64 encoded `flag || privkey`, the network keypair, protocol
/// keypair, authority keypair as Base64 encoded `privkey`.
LoadKeypair { file: PathBuf },
/// To MultiSig Iota Address. Pass in a list of all public keys `flag || pk`
/// in Base64. See `keytool list` for example public keys.
MultiSigAddress {
Expand Down Expand Up @@ -220,11 +213,6 @@ pub enum KeyToolCommand {
#[clap(long)]
base64pk: String,
},
/// This takes a bech32 encoded [enum IotaKeyPair]. It outputs the keypair
/// into a file at the current directory where the address is the
/// filename, and prints out its Iota address, Base64 encoded public
/// key, the key scheme, and the key scheme flag.
Unpack { keypair: String },
// Commented for now: https://github.com/iotaledger/iota/issues/1777
// /// Given the max_epoch, generate an OAuth url, ask user to paste the
// /// redirect with id_token, call salt server, then call the prover server,
Expand Down Expand Up @@ -356,15 +344,6 @@ pub struct ExportedKey {
key: Key,
}

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct KeypairData {
account_keypair: String,
network_keypair: Option<String>,
protocol_keypair: Option<String>,
key_scheme: String,
}

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MultiSigAddress {
Expand Down Expand Up @@ -456,7 +435,6 @@ pub enum CommandOutput {
Import(Key),
Export(ExportedKey),
List(Vec<Key>),
LoadKeypair(KeypairData),
MultiSigAddress(MultiSigAddress),
MultiSigCombinePartialSig(MultiSigCombinePartialSig),
Show(Key),
Expand Down Expand Up @@ -665,44 +643,6 @@ impl KeyToolCommand {
}
CommandOutput::List(keys)
}
KeyToolCommand::LoadKeypair { file } => {
let output = match read_keypair_from_file(&file) {
Ok(keypair) => {
// Account keypair is encoded with the key scheme flag {},
// and network and protocol keypair are not.
let network_protocol_keypair = match &keypair {
IotaKeyPair::Ed25519(kp) => kp.encode_base64(),
IotaKeyPair::Secp256k1(kp) => kp.encode_base64(),
IotaKeyPair::Secp256r1(kp) => kp.encode_base64(),
};
KeypairData {
account_keypair: keypair.encode_base64(),
network_keypair: Some(network_protocol_keypair.clone()),
protocol_keypair: Some(network_protocol_keypair),
key_scheme: keypair.public().scheme().to_string(),
}
}
Err(_) => {
// Authority keypair file is not stored with the flag, it will try read as
// BLS keypair..
match read_authority_keypair_from_file(&file) {
Ok(keypair) => KeypairData {
account_keypair: keypair.encode_base64(),
network_keypair: None,
protocol_keypair: None,
key_scheme: SignatureScheme::BLS12381.to_string(),
},
Err(e) => {
return Err(anyhow!(format!(
"Failed to read keypair at path {:?} err: {:?}",
file, e
)));
}
}
}
};
CommandOutput::LoadKeypair(output)
}
KeyToolCommand::MultiSigAddress {
threshold,
pks,
Expand Down Expand Up @@ -854,16 +794,7 @@ impl KeyToolCommand {
serialized_sig_base64: serialized_sig,
})
}
KeyToolCommand::Unpack { keypair } => {
let key = Key::from(
&IotaKeyPair::decode(&keypair)
.map_err(|_| anyhow!("Invalid Bech32 encoded keypair"))?,
);
let path_str = format!("{}.key", key.iota_address).to_lowercase();
let path = Path::new(&path_str);
fs::write(path, keypair)?;
CommandOutput::Show(key)
} /* Commented for now: https://github.com/iotaledger/iota/issues/1777
/* Commented for now: https://github.com/iotaledger/iota/issues/1777
* KeyToolCommand::ZkLoginInsecureSignPersonalMessage { data, max_epoch } => {
* let msg = PersonalMessage {
* message: data.as_bytes().to_vec(),
Expand Down
5 changes: 0 additions & 5 deletions docs/content/references/cli/keytool.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ Commands:
provided, the tool will automatically generate one
export Output the private key of the given key identity in Iota CLI Keystore as Bech32 encoded string starting with `iotaprivkey`
list List all keys by its Iota address, Base64 encoded public key, key scheme name in iota.keystore
load-keypair This reads the content at the provided file path. The accepted format can be [enum IotaKeyPair] (Base64 encoded of 33-byte `flag || privkey`) or `type
AuthorityKeyPair` (Base64 encoded `privkey`). This prints out the account keypair as Base64 encoded `flag || privkey`, the network keypair, protocol keypair,
authority keypair as Base64 encoded `privkey`
multi-sig-address To MultiSig Iota Address. Pass in a list of all public keys `flag || pk` in Base64. See `keytool list` for example public keys
multi-sig-combine-partial-sig Provides a list of participating signatures (`flag || sig || pk` encoded in Base64), threshold, a list of all public keys and a list of their weights that
define the MultiSig address. Returns a valid MultiSig signature and its sender address. The result can be used as signature field for `iota client
Expand All @@ -43,8 +40,6 @@ Commands:
sign-kms Creates a signature by leveraging AWS KMS. Pass in a key-id to leverage Amazon KMS to sign a message and the base64 pubkey. Generate PubKey from pem using
iotaledger/base64pemkey Any signature commits to a [struct IntentMessage] consisting of the Base64 encoded of the BCS serialized transaction bytes itself and
its intent. If intent is absent, default will be used
unpack This takes [enum IotaKeyPair] of Base64 encoded of 33-byte `flag || privkey`). It outputs the keypair into a file at the current directory where the address is
the filename, and prints out its Iota address, Base64 encoded public key, the key scheme, and the key scheme flag
help Print this message or the help of the given subcommand(s)
Options:
Expand Down
4 changes: 2 additions & 2 deletions sdk/graphql-transport/src/generated/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export type AuthenticatorStateCreateTransaction = {

export type AuthenticatorStateExpireTransaction = {
__typename?: 'AuthenticatorStateExpireTransaction';
/** The initial version that the AuthenticatorStateUpdate was shared at. */
/** The initial version that the AuthenticatorStateUpdateV1 was shared at. */
authenticatorObjInitialSharedVersion: Scalars['UInt53']['output'];
/** Expire JWKs that have a lower epoch than this. */
minEpoch?: Maybe<Epoch>;
Expand Down Expand Up @@ -5018,7 +5018,7 @@ export type Validator = {
stakingPool?: Maybe<MoveObject>;
/** The epoch at which this pool became active. */
stakingPoolActivationEpoch?: Maybe<Scalars['UInt53']['output']>;
/** The ID of this validator's `0x3::staking_pool::StakingPool`. */
/** The ID of this validator's `0x3::staking_pool::StakingPoolV1`. */
stakingPoolId: Scalars['IotaAddress']['output'];
/** The total number of IOTA tokens in this pool. */
stakingPoolIotaBalance?: Maybe<Scalars['BigInt']['output']>;
Expand Down
1 change: 1 addition & 0 deletions sdk/graphql-transport/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ export const RPC_METHODS: {
iotaTotalSupply: String(systemState.iotaTotalSupply),
iotaTreasuryCapId: String(systemState.iotaTreasuryCapId),
maxValidatorCount: String(systemState.systemParameters?.maxValidatorCount),
minValidatorCount: String(systemState.systemParameters?.minValidatorCount),
minValidatorJoiningStake: String(
systemState.systemParameters?.minValidatorJoiningStake,
),
Expand Down
9 changes: 7 additions & 2 deletions sdk/typescript/src/client/types/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export interface EndOfEpochInfo {
epochEndTimestamp: string;
lastCheckpointId: string;
mintedTokensAmount: string;
/** existing fields from `SystemEpochInfoEvent` (without epoch) */
/** existing fields from `SystemEpochInfoEventV1` (without epoch) */
protocolVersion: string;
referenceGasPrice: string;
storageCharge: string;
Expand Down Expand Up @@ -690,6 +690,11 @@ export interface IotaSystemStateSummary {
* epoch to go above this.
*/
maxValidatorCount: string;
/**
* Minimum number of active validators at any moment. We do not allow the number of validators in any
* epoch to go under this.
*/
minValidatorCount: string;
/** Lower-bound on the amount of stake required to become a validator. */
minValidatorJoiningStake: string;
/** ID of the object that contains the list of new validators that will join at the end of the epoch. */
Expand Down Expand Up @@ -1479,7 +1484,7 @@ export type IotaTransactionBlockKind =
} /** A transaction which updates global authenticator state */
| {
epoch: string;
kind: 'AuthenticatorStateUpdate';
kind: 'AuthenticatorStateUpdateV1';
new_active_jwks: IotaActiveJwk[];
round: string;
} /** A transaction which updates global randomness state */
Expand Down
4 changes: 2 additions & 2 deletions sdk/typescript/src/graphql/generated/2024.10/schema.graphql

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

0 comments on commit ca3ae52

Please sign in to comment.