Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🥶 Slightly BelowZero #32

Closed
wants to merge 5 commits into from
Closed

🥶 Slightly BelowZero #32

wants to merge 5 commits into from

Conversation

janjakubnanista
Copy link
Contributor

@janjakubnanista janjakubnanista commented Nov 21, 2023

In this PR

A stub of a BelowZero-like functionality for UA configuration. It builds around a concept of Property - a structure that has:

  • a current/actual value, obtained by a getter
  • a desired value, obtained by a desired value getter
  • a way to transition between the actual and desired value, represented by a setter

Property itself does not impose any restrictions on any of these, neither structural nor executional. This means a property can:

  • Work with a single primitive value on a contract directly
  • Work with multiple values on a contract
  • Submit values to the contract directly
  • Populate transactions and pass them on for further execution
  • ... you name it it will do it

Properties define their context - a value or set of values that they require to be able to get/set their state. The context is strongly typed and required to evaluate a property, i.e. to turn a property into a PropertyState:

const property = createProperty({ ... })

// Some properties might work with no context
const state = property();

// Other require some simple context
const state = property(someContract);

// And other might need more information still
const state = property(someContract, someParameter, someOtherParameter);

Result of the evaluation is a PropertyState that comes in two varieties:

  • Configured represents a state where desired and actual values match, no action needed
  • Misconfigured represents a state where an action is needed to synchronize current and desired states

To ease the work with these two, isConfigured and isMisconfigured utilities are provided:

const state = property(someContract);

if (isMisconfigured(state)) {
  // log something or whatnot
}

@janjakubnanista janjakubnanista changed the title 🥶 Slightly below zero 🥶 Slightly BelowZero Nov 21, 2023
@janjakubnanista janjakubnanista deleted the slightly-below-zero branch December 12, 2023 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants