@@ -9,8 +9,8 @@ use aurora_engine_types::parameters::connector::{
99 PausedMask , SetErc20MetadataArgs , SetEthConnectorContractAccountArgs , WithdrawSerializeType ,
1010} ;
1111use aurora_engine_types:: parameters:: engine:: {
12- CallArgs , FunctionCallArgsV2 , GetStorageAtArgs , NewCallArgs , NewCallArgsV2 ,
13- PausePrecompilesCallArgs , RelayerKeyArgs , RelayerKeyManagerArgs , SetOwnerArgs ,
12+ CallArgs , DeployErc20TokenArgs , FunctionCallArgsV2 , GetStorageAtArgs , NewCallArgs ,
13+ NewCallArgsV2 , PausePrecompilesCallArgs , RelayerKeyArgs , RelayerKeyManagerArgs , SetOwnerArgs ,
1414 SetUpgradeDelayBlocksArgs , SubmitResult , TransactionStatus ,
1515} ;
1616use aurora_engine_types:: parameters:: xcc:: FundXccArgs ;
@@ -778,6 +778,28 @@ pub async fn set_erc20_metadata(
778778 . await
779779}
780780
781+ /// Deploy a new ERC-20 contract.
782+ pub async fn deploy_erc20_token (
783+ context : Context ,
784+ nep141 : String ,
785+ with_metadata : bool ,
786+ ) -> anyhow:: Result < ( ) > {
787+ let nep141_account_id = nep141. parse ( ) . map_err ( |e| anyhow:: anyhow!( "{e}" ) ) ?;
788+ let args = borsh:: to_vec ( & if with_metadata {
789+ DeployErc20TokenArgs :: WithMetadata ( nep141_account_id)
790+ } else {
791+ DeployErc20TokenArgs :: Legacy ( nep141_account_id)
792+ } ) ?;
793+
794+ contract_call ! (
795+ "deploy_erc20_token" ,
796+ "ERC-20 token has been deployed successfully" ,
797+ "Error while deploying ERC-20 token"
798+ )
799+ . proceed ( context, args)
800+ . await
801+ }
802+
781803/// Mirror ERC-20 contract.
782804pub async fn mirror_erc20_token (
783805 context : Context ,
@@ -1039,7 +1061,17 @@ impl ContractCall<'_> {
10391061 // TODO: The output could be serialized with JSON or Borsh.
10401062 // TODO: In the case of Borsh we should provide a type for deserializing the output in the corresponding object.
10411063 OutputFormat :: Plain => match to_string_pretty ( & output) {
1042- Ok ( msg) if !output. is_empty ( ) => println ! ( "{}\n {msg}" , self . success_message) ,
1064+ Ok ( msg) if !output. is_empty ( ) => {
1065+ // TODO: Add optional argument `fn(&[u8]) -> String` which will generate a custom output message.
1066+ if self . method == "deploy_erc20_token"
1067+ || self . method == "mirror_erc20_token"
1068+ {
1069+ let address = hex:: encode ( & output) ;
1070+ println ! ( "{}, ERC-20 address: 0x{address}" , self . success_message)
1071+ } else {
1072+ println ! ( "{}: {msg}" , self . success_message)
1073+ }
1074+ }
10431075 Ok ( _) | Err ( _) => println ! ( "{}" , self . success_message) ,
10441076 } ,
10451077 OutputFormat :: Json => {
0 commit comments