Skip to content

Contract-key API #7

@sanity

Description

@sanity

A WebAssembly contract-key will implement the following functions:

trait ContractKey {
  /// Determine whether this value is valid for this contract
  fn validate_value(value : &Vec<u8>) -> bool;

  /// Determine whether this value is a valid update for this contract. If it is, modify
  /// the value and return true, else return false.
  fn update_value(value: &mut Vec<u8>, value_update: &Vec<u8>) -> bool;

  /// Obtain any other related contracts for this value update. Typicall used to ensure 
  /// update has been fully propagated.
  fn related_contracts(value_update : &Vec<u8>) -> Vec<ContractKey>;

  /// Extract some data from the value and return it.
  ///
  /// eg. `extractor` might contain a byte range, which will be extracted
  /// from the value and returned.
  fn extract(extractor : &Vec<u8>, value : &Vec<u8>) -> Vec<u8>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-featureType: New functionality request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions