Skip to content

Add contractID to contract state (aka rootState[contractID]) #46

@corrideat

Description

@corrideat

Problem

There are two ways that Chelonia can work on a contract. In many functions we use the contractIDOrState convention that allows passing in a contract ID (in which case, we do rootState[contractID]), or we allow the state to be passed in directly.

Depending on use case, one or the other might be more appropriate. However, if these selectors or functions are being called from a contract, the one taking the state directly often is the more adequate choice, and this state is a different object than the state at the root.

Mostly for logging, we would like to have access to the contractID when a state is passed. We could pass the ID as a parameter, but since it's not possible to check its correctness, there's a chance that it might be wrong.

A more robust and DRYer solution is to include the contractID in the state (e.g., as _vm.contractID), with some guards that ensure its immutable.

Solution

Add _vm.contractID to the state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions