essential-contributions / pint

Pint, the constraint-based programming language for declarative blockchains
Apache License 2.0
17 stars 3 forks source link

Abi gen state mutations #776

Open freesig opened 3 months ago

freesig commented 3 months ago

This isn't urgent but it might be more correct to make it so when constructing Mutations for a given contract, you can only construct each mutation once because it's invalid to propose a mutation to the same key twice in the same solution. Maybe something like:

struct Empty;
struct Owners<T>;
struct Nonce<T>;
struct TokenName<T>;
struct Mutations<T>;

impl Mutations<Owners<Nonce<TokenName<Empty>>>> {
  fn owners(...) -> Mutations<Nonce<TokenName<Empty>>> { .. }
  fn nonce(...) -> Mutations<Owners<TokenName<Empty>>> { .. }
  fn token_name(...) -> Mutations<Owners<Nonce<Empty>>> { .. }
}
impl Mutations<Nonce<TokenName<Empty>>> {
  fn nonce(...) -> Mutations<TokenName<Empty>> { .. }
  fn token_name(...) -> Mutations<Nonce<Empty>> { .. }
}
impl Mutations<Owners<TokenName<Empty>>> {
  fn owners(...) -> Mutations<TokenName<Empty>> { .. }
  fn token_name(...) -> Mutations<Owners<Empty>> { .. }
}
impl Mutations<Owners<Nonce<Empty>>> {
  fn owners(...) -> Mutations<Nonce<Empty>> { .. }
  fn nonce(...) -> Mutations<Owners<Empty>> { .. }
}
impl Mutations<Owners<Empty>> {
  fn owners(...) -> Mutations<Empty> { .. }
}
impl Mutations<Nonce<Empty>> {
  fn nonce(...) -> Mutations<Empty> { .. }
}
impl Mutations<TokenName<Empty>> {
  fn token_name(...) -> Mutations<Empty> { .. }
}
freesig commented 3 months ago

Actually my suggestion doesn't work exactly because you can mutate different keys in the same map (like owners). Not sure the best way to solve this.