diff --git a/ant-cli/src/commands/register.rs b/ant-cli/src/commands/register.rs index 0aad3ab844..17c30b2559 100644 --- a/ant-cli/src/commands/register.rs +++ b/ant-cli/src/commands/register.rs @@ -67,7 +67,7 @@ pub async fn create(name: &str, value: &str, public: bool, peers: Vec let permissions = RegisterPermissions::new_anyone_can_write(); client .register_create_with_permissions( - value.as_bytes().to_vec().into(), + Some(value.as_bytes().to_vec().into()), name, register_key, permissions, @@ -80,7 +80,7 @@ pub async fn create(name: &str, value: &str, public: bool, peers: Vec info!("With private write access"); client .register_create( - value.as_bytes().to_vec().into(), + Some(value.as_bytes().to_vec().into()), name, register_key, &wallet, diff --git a/ant-node/tests/data_with_churn.rs b/ant-node/tests/data_with_churn.rs index 64b3064350..053102fb81 100644 --- a/ant-node/tests/data_with_churn.rs +++ b/ant-node/tests/data_with_churn.rs @@ -285,7 +285,12 @@ fn create_registers_task( let mut retries = 1; loop { match client - .register_create(random_data.clone(), &random_name, owner.clone(), &wallet) + .register_create( + Some(random_data.clone()), + &random_name, + owner.clone(), + &wallet, + ) .await { Ok(register) => { diff --git a/ant-node/tests/verify_data_location.rs b/ant-node/tests/verify_data_location.rs index 0a82634ffe..a15a0e18be 100644 --- a/ant-node/tests/verify_data_location.rs +++ b/ant-node/tests/verify_data_location.rs @@ -396,7 +396,12 @@ async fn store_registers( .map(char::from) .collect(); let register = client - .register_create(vec![1, 2, 3, 4].into(), &rand_name, key.clone(), wallet) + .register_create( + Some(vec![1, 2, 3, 4].into()), + &rand_name, + key.clone(), + wallet, + ) .await?; println!("Created Register at {:?}", register.address()); diff --git a/autonomi/src/client/registers.rs b/autonomi/src/client/registers.rs index 8a032399a5..0d19fb27fe 100644 --- a/autonomi/src/client/registers.rs +++ b/autonomi/src/client/registers.rs @@ -265,12 +265,12 @@ impl Client { RegisterAddress::new(name, pk) } - /// Creates a new Register with a name and an initial value and uploads it to the network. + /// Creates a new Register with a name and optional initial value and uploads it to the network. /// /// The Register is created with the owner as the only writer. pub async fn register_create( &self, - value: Bytes, + value: Option, name: &str, owner: RegisterSecretKey, wallet: &EvmWallet, @@ -282,12 +282,12 @@ impl Client { .await } - /// Creates a new Register with a name and an initial value and uploads it to the network. + /// Creates a new Register with a name and optional initial value and uploads it to the network. /// /// Unlike `register_create`, this function allows you to specify the permissions for the register. pub async fn register_create_with_permissions( &self, - value: Bytes, + value: Option, name: &str, owner: RegisterSecretKey, permissions: RegisterPermissions, @@ -297,7 +297,7 @@ impl Client { let name = XorName::from_content_parts(&[name.as_bytes()]); // Owner can write to the register. - let register = Register::new(Some(value), name, owner, permissions)?; + let register = Register::new(value, name, owner, permissions)?; let address = register.address(); let reg_xor = address.xorname(); diff --git a/autonomi/tests/register.rs b/autonomi/tests/register.rs index 266908c293..e698809d46 100644 --- a/autonomi/tests/register.rs +++ b/autonomi/tests/register.rs @@ -34,7 +34,12 @@ async fn register() -> Result<()> { .map(char::from) .collect(); let register = client - .register_create(vec![1, 2, 3, 4].into(), &rand_name, key.clone(), &wallet) + .register_create( + Some(vec![1, 2, 3, 4].into()), + &rand_name, + key.clone(), + &wallet, + ) .await .unwrap();