Skip to content

Allow contract state to include different #131

Merged
someone235 merged 8 commits into
kaspanet:masterfrom
someone235:structs
Jun 16, 2026
Merged

Allow contract state to include different #131
someone235 merged 8 commits into
kaspanet:masterfrom
someone235:structs

Conversation

@someone235

Copy link
Copy Markdown
Contributor

Language Behavior Changes

  • validateOutputStateWithTemplate no longer accepts inline state object literals directly. Assign the value to a typed struct variable first so the compiler can use that struct layout.
TargetState next = {y: 0x3412, x: x + 1, targetHash: targetHash};
validateOutputStateWithTemplate(0, next, prefix, suffix, templateHash);
  • Nested struct field paths are preserved during template validation, so fields with the same leaf name under different nested structs remain distinct.
      contract M(int initLeft, int initRight) {
          struct Left {
              int id;
          }

          struct Right {
              int id;
          }

          Left left = {id: initLeft};
          Right right = {id: initRight};

          entrypoint function route() {
              State next = {
                  left: {id: 3},
                  right: {id: 4}
              };
              validateOutputState(0, next);
          }
      }

@someone235 someone235 merged commit faaa074 into kaspanet:master Jun 16, 2026
4 checks passed
@someone235 someone235 deleted the structs branch June 16, 2026 05:18
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.

1 participant