diff --git a/workspaces/src/network/sandbox.rs b/workspaces/src/network/sandbox.rs index 1ac29fe4..fee4cfb1 100644 --- a/workspaces/src/network/sandbox.rs +++ b/workspaces/src/network/sandbox.rs @@ -182,6 +182,10 @@ impl RootAccountSubaccountCreator for Sandbox { subaccount_prefix: AccountId, sk: SecretKey, ) -> Result> { + if subaccount_prefix.as_str().contains('.') { + return Err(crate::error::ErrorKind::Io + .custom("Subaccount prefix for subaccount created cannot contain '.'")); + } let root_id = self.root_account_id()?; let id = AccountId::from_str(format!("{}.{}", subaccount_prefix, root_id).as_str()) .map_err(|e| ErrorKind::DataConversion.custom(e))?; @@ -203,6 +207,10 @@ impl RootAccountSubaccountCreator for Sandbox { sk: SecretKey, wasm: &[u8], ) -> Result> { + if subaccount_prefix.as_str().contains('.') { + return Err(crate::error::ErrorKind::Io + .custom("Subaccount prefix for subaccount created cannot contain '.'")); + } let root_id = self.root_account_id()?; let id = AccountId::from_str(format!("{}.{}", subaccount_prefix, root_id).as_str()) .map_err(|e| ErrorKind::DataConversion.custom(e))?; diff --git a/workspaces/src/network/testnet.rs b/workspaces/src/network/testnet.rs index 4de14bbb..c4d2272d 100644 --- a/workspaces/src/network/testnet.rs +++ b/workspaces/src/network/testnet.rs @@ -79,6 +79,10 @@ impl RootAccountSubaccountCreator for Testnet { sk: SecretKey, // TODO: return Account only, but then you don't get metadata info for it... ) -> Result> { + if subaccount_prefix.as_str().contains('.') { + return Err(crate::error::ErrorKind::Io + .custom("Subaccount prefix for subaccount created cannot contain '.'")); + } let url = Url::parse(HELPER_URL).unwrap(); let root_id = self .root_account_id() diff --git a/workspaces/src/network/variants.rs b/workspaces/src/network/variants.rs index 902769fa..5478559e 100644 --- a/workspaces/src/network/variants.rs +++ b/workspaces/src/network/variants.rs @@ -22,7 +22,7 @@ pub trait NetworkInfo { /// For example, if this parameter is `"subaccount"` then /// the full ID for testnet will be `"subaccount.testnet"`. /// -/// It is expected that the `subaccount_prefix` does not contain a `.`. +/// Currently all implementations validate that `subaccount_prefix` does not contain a `.`. #[async_trait] pub trait RootAccountSubaccountCreator { /// for sandbox value of [`Worker::::root_account`] @@ -136,10 +136,6 @@ where subaccount_prefix: AccountId, sk: SecretKey, ) -> Result> { - if subaccount_prefix.as_str().contains('.') { - return Err(crate::error::ErrorKind::Io - .custom("Subaccount prefix for subaccount created cannot contain '.'")); - } let res = self .workspace .create_root_account_subaccount(self.clone().coerce(), subaccount_prefix, sk) @@ -158,10 +154,6 @@ where sk: SecretKey, wasm: &[u8], ) -> Result> { - if subaccount_prefix.as_str().contains('.') { - return Err(crate::error::ErrorKind::Io - .custom("Subaccount prefix for subaccount created cannot contain '.'")); - } let res = self .workspace .create_root_account_subaccount_and_deploy(