There is no struct Ownership in src-5

Hi guys, last week we integrated our standards including src-5, it looks something like this here

According to this documentation, we create an Ownership object
But after this commit Ownership is no longer there, can you please tell me how to do it now?

But after this commit Ownership is no longer there, can you please tell me how to do it now?

The documentation described in the linked issue does not use a struct, but an enum:

impl SRC_5 for Contract {
     fn owner() -> State {
          if OWNER == ZERO_B256 {
               State::Uninitialized
          } else {
               State::Initialized(Identity::Address(Address::from(OWNER))
          }
      }
}

As the SRC-5 Standard states, the owner() function should return an enum State with one of three variants: Uninitialized, Initalizlied, or Revoked. It does not describe the implementation design, as to not be restricting on design or limiting on future capabilities. Whether you use a struct or enum to store in storage is entirely up to you.

Note that the example above removes the need for storage entirely as OWNER is a defined constant. If ownership may change during the life of this contract, then it should be added as a storage variable instead. State can be stored directly as an enum or within a struct depending on your use case.

The separate convenience library Ownership Library does use a struct in its current release, however it is not up to date with Sway-Standards v0.2.0. There is currently a Pull Request to bring this up to date. Any changes made will be reflected in the documentation for that library, but the SRC-5 standard has not and will not change.

1 Like

I believe the term ‘State’ naming fails to adequately capture the essence of ‘Ownership State’. It seems more appropriate to have a term like ‘Ownership Status’ in my starter contacts, as this would better reflect the intended meaning. Therefore, I suggest renaming it to something more fitting, such as ‘Ownership Status’ or a similar alternative.

1 Like