Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(x/intent)!: ability for modules to dynamically resolve variables…
… on Action creation (#139) * feat(wardend): prefer context.Context over sdk.Context where possible This allow us to pass other context to functions. In the future we might exploit this feature for enriching the sdk.Context with more fields. * feat(shield): move Environment interface out of internal package Even if it was type-aliased (= re-exported), the depinject pkg from Cosmos SDK didn't like it. Since Environment is commonly accessed from outside of shield, it makes sense to move it outside the internal/ dir anyway. * feat(shield): allow dots (.) in identifier names In this version of shield we'll treat dots as part of the identifier (i.e. we won't dig much into building "javascript objects" equivalents). It'll be up to the Environment resolving the identifier to do whatever it prefers. E.g. `warden.space.owners` will be treated as a single name. The resolution env from x/warden can split by '.' and resolve 'space' properties individually. * chore(shield): move `ast` outside internal folder * feat(shield): add custom AST preprocessing This allows anyone to plug-in an implementer of the Expander interface to change the AST into another AST by replacing any Identifier with another AST node. This will be useful for resolving some Identifiers into Warden addresses and freeze them in time (e.g. when an Action is created). * feat(shield): add ast.Stringify method to translate an AST back into its string definition * feat(x/intent): inject a constructor for a shield.Expander We'll use the Expander later, when creating an Action, to process the Intent definition at the time the Action is created. * feat(x/intent): provide an ast.Expander implementation The ExpanderManager will dispatch Expander calls based on "namespace", i.e. the first part of an identifier (separated by a dot). * fix(x/intent): don't run preprocessors when evaluating the Intent * feat(x/intent): move and rename Intent.Addresses to Action.Mentions This way we can populate this field *after* preprocessing. The Intent stored in the database will have the original definition written by the user, the Intent stored inside the Action will be preprocessed (so the user knows exactly what's being evaluated to decide on its Action). * feat(x/intent): extend a Context adding the Action msg being processed * feat(x/intent): freeze Intent after preprocessing during Action creation * chore: remove older migrations code * feat(x/warden): provide shield.Expander for warden module In this initial version, it's able to expand `space.owners` in the list of owners for the space. Only sdk.Msgs that have a SpaceId field are supported at this time. * feat(x/warden): rewrite the default intent using the new language features * chore: changelog * Update warden/x/warden/keeper/shield.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * chore: fix changelog scope * feat: proper error handling for ast.Expanders --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information