-
Notifications
You must be signed in to change notification settings - Fork 9
rune: add support for DI via env #517
Comments
For context: this will serve as a means of DI in Runes (for instance, injecting a custom logger, or runtime client)... perhaps a rune-ified paritytech/zones#20 (although may have a very different API, we shall see). |
Perhaps our DI approach can satisfy the use case of #706: consumers of pattern libs could hook into parts of the pattern's execution at pattern-dev-defined waypoints. |
Idea for this feature: // 1. Define a key, to be used for applying to the placeholder.
const userId = Symbol()
// 2. Define a rune containing a placeholder(s) (the output of the `Rune.env` factory).
const free = System.Account
.value(Rune.env(userId))
.unhandle(undefined)
.access("data", "free")
// 3. Apply a value/rune to the placeholder at any point in the tree.
const alexaFree = free.apply(userId, alexa.publicKey) It's worth noting that in step 2, the type of This feature will be especially useful for the injection of custom lifecycle handlers into patterns. Consider the virtual multisig pattern: currently, this pattern is a black box. It creates many pure proxies, submits existential deposits, performs ownership swaps and more. In the future, this pattern can expose symbols to be used for (optionally) applying callbacks to hook placeholders. await VirtualMultisigRune
.deployment(chain, {
founders: [alexa.publicKey, billy.publicKey, carol.publicKey],
threshold: 2,
})
.signed(signature({ sender: alexa }))
.apply(onOwnershipSwap, (events) => { /* ... */ })
.run() The root |
Like #516, I think this should happen outside of #454.
The text was updated successfully, but these errors were encountered: