Skip to content

Commit 2ce8412

Browse files
committed
feat(cast): shimmy old convert cast commands
1 parent 5362d4c commit 2ce8412

File tree

2 files changed

+450
-0
lines changed

2 files changed

+450
-0
lines changed

crates/cast/src/args.rs

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::cmd::convert::{ConvertSubCommand, ToBaseArgs as ConvertToBaseArgs};
12
use crate::{
23
Cast, SimpleCast,
34
cmd::erc20::IERC20,
@@ -26,6 +27,7 @@ use foundry_common::{
2627
},
2728
shell, stdin,
2829
};
30+
2931
use std::time::Instant;
3032

3133
/// Run the `cast` command-line interface.
@@ -643,6 +645,174 @@ pub async fn run_command(args: CastArgs) -> Result<()> {
643645
CastSubcommand::Convert { command } => {
644646
command.run().await?;
645647
}
648+
649+
// Conversions and transformations (soon to be deprecated)
650+
CastSubcommand::FromUtf8 { text } => {
651+
eprintln!(
652+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert from-utf8' instead"
653+
);
654+
ConvertSubCommand::FromUtf8 { text }.run().await?;
655+
}
656+
CastSubcommand::ToAscii { hexdata } => {
657+
eprintln!(
658+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-ascii' instead"
659+
);
660+
ConvertSubCommand::ToAscii { hexdata }.run().await?;
661+
}
662+
CastSubcommand::ToUtf8 { hexdata } => {
663+
eprintln!(
664+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-utf8' instead"
665+
);
666+
ConvertSubCommand::ToUtf8 { hexdata }.run().await?;
667+
}
668+
CastSubcommand::FromFixedPoint { value, decimals } => {
669+
eprintln!(
670+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert from-fixed-point' instead"
671+
);
672+
ConvertSubCommand::FromFixedPoint { value, decimals }.run().await?;
673+
}
674+
CastSubcommand::ToFixedPoint { value, decimals } => {
675+
eprintln!(
676+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-fixed-point' instead"
677+
);
678+
ConvertSubCommand::ToFixedPoint { value, decimals }.run().await?;
679+
}
680+
CastSubcommand::ConcatHex { data } => {
681+
eprintln!(
682+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert concat-hex' instead"
683+
);
684+
ConvertSubCommand::ConcatHex { data }.run().await?;
685+
}
686+
CastSubcommand::FromBin => {
687+
eprintln!(
688+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert from-bin' instead"
689+
);
690+
ConvertSubCommand::FromBin.run().await?;
691+
}
692+
CastSubcommand::ToHexdata { input } => {
693+
eprintln!(
694+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-hexdata' instead"
695+
);
696+
ConvertSubCommand::ToHexdata { input }.run().await?;
697+
}
698+
CastSubcommand::ToCheckSumAddress { address, chain_id } => {
699+
eprintln!(
700+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-checksum-address' instead"
701+
);
702+
ConvertSubCommand::ToCheckSumAddress { address, chain_id }.run().await?;
703+
}
704+
CastSubcommand::ToUint256 { value } => {
705+
eprintln!(
706+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-uint256' instead"
707+
);
708+
ConvertSubCommand::ToUint256 { value }.run().await?;
709+
}
710+
CastSubcommand::ToInt256 { value } => {
711+
eprintln!(
712+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-int256' instead"
713+
);
714+
ConvertSubCommand::ToInt256 { value }.run().await?;
715+
}
716+
CastSubcommand::ToUnit { value, unit } => {
717+
eprintln!(
718+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-unit' instead"
719+
);
720+
ConvertSubCommand::ToUnit { value, unit }.run().await?;
721+
}
722+
CastSubcommand::ParseUnits { value, unit } => {
723+
eprintln!(
724+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert parse-units' instead"
725+
);
726+
ConvertSubCommand::ParseUnits { value, unit }.run().await?;
727+
}
728+
CastSubcommand::FormatUnits { value, unit } => {
729+
eprintln!(
730+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert format-units' instead"
731+
);
732+
ConvertSubCommand::FormatUnits { value, unit }.run().await?;
733+
}
734+
CastSubcommand::FromWei { value, unit } => {
735+
eprintln!(
736+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert from-wei' instead"
737+
);
738+
// Delegate to convert command instead of duplicating logic
739+
ConvertSubCommand::FromWei { value, unit }.run().await?;
740+
}
741+
CastSubcommand::ToWei { value, unit } => {
742+
eprintln!(
743+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-wei' instead"
744+
);
745+
ConvertSubCommand::ToWei { value, unit }.run().await?;
746+
}
747+
CastSubcommand::FromRlp { value, as_int } => {
748+
eprintln!(
749+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert from-rlp' instead"
750+
);
751+
ConvertSubCommand::FromRlp { value, as_int }.run().await?;
752+
}
753+
CastSubcommand::ToRlp { value } => {
754+
eprintln!(
755+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-rlp' instead"
756+
);
757+
ConvertSubCommand::ToRlp { value }.run().await?;
758+
}
759+
CastSubcommand::ToHex(ToBaseArgs { value, base_in }) => {
760+
eprintln!(
761+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-hex' instead"
762+
);
763+
ConvertSubCommand::ToHex(crate::cmd::convert::ToBaseArgs { value, base_in })
764+
.run()
765+
.await?;
766+
}
767+
CastSubcommand::ToDec(ToBaseArgs { value, base_in }) => {
768+
eprintln!(
769+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-dec' instead"
770+
);
771+
ConvertSubCommand::ToDec(crate::cmd::convert::ToBaseArgs { value, base_in })
772+
.run()
773+
.await?;
774+
}
775+
CastSubcommand::ToBase { base: ToBaseArgs { value, base_in }, base_out } => {
776+
eprintln!(
777+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-base' instead"
778+
);
779+
ConvertSubCommand::ToBase {
780+
base: crate::cmd::convert::ToBaseArgs { value, base_in },
781+
base_out,
782+
}
783+
.run()
784+
.await?;
785+
}
786+
CastSubcommand::ToBytes32 { bytes } => {
787+
eprintln!(
788+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert to-bytes32' instead"
789+
);
790+
ConvertSubCommand::ToBytes32 { bytes }.run().await?;
791+
}
792+
CastSubcommand::Pad { data, right, left, len } => {
793+
eprintln!(
794+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert pad' instead"
795+
);
796+
ConvertSubCommand::Pad { data, right, left, len }.run().await?;
797+
}
798+
CastSubcommand::FormatBytes32String { string } => {
799+
eprintln!(
800+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert format-bytes32-string' instead"
801+
);
802+
ConvertSubCommand::FormatBytes32String { string }.run().await?;
803+
}
804+
CastSubcommand::ParseBytes32String { bytes } => {
805+
eprintln!(
806+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert parse-bytes32-string' instead"
807+
);
808+
ConvertSubCommand::ParseBytes32String { bytes }.run().await?;
809+
}
810+
CastSubcommand::ParseBytes32Address { bytes } => {
811+
eprintln!(
812+
"⚠️ This command is deprecated and may be removed in the future, please use 'cast convert parse-bytes32-address' instead"
813+
);
814+
ConvertSubCommand::ParseBytes32Address { bytes }.run().await?;
815+
}
646816
};
647817

648818
/// Prints slice of tokens using [`format_tokens`] or [`serialize_value_as_json`] depending

0 commit comments

Comments
 (0)