Dependencies

Each Account explicitly declares and migrates to new versions of package dependencies that are authorized to modify their state. This approach ensures that only authorized code can interact with the account.

Deps

By default, the Account must have AccountProtocol and AccountConfig as its first dependencies, with the latter being the package that defines the Account type. Optionally, one can add AccountActions, which provides built-in actions and intents, and any other packages.

A dependency is defined by a name, a package ID, and a version.

public struct Dep has copy, drop, store {
    // name of the package
    name: String,
    // id of the package
    addr: address,
    // version of the package
    version: u64,
}

Dependencies are tracked in the custom Deps field of the Account.

public struct Deps has copy, drop, store {
    inner: vector<Dep>,
    // can community extensions be added
    unverified_allowed: bool,
}

Extensions

The Deps struct includes an unverified_allowed flag. By default, an Account can only add verified packages as dependencies. The account.tech team curates a collection of these verified packages in the Extensions shared object.

By enabling unverified dependencies, account members can add arbitrary packages as dependencies. This allows developers to use their own code to interact with an Account.

VersionWitness

In Move, there is no native way to determine which package, module, or function is being called. TxContext provides very limited information, so we developed a new pattern to track package versions and their addresses.

The "Version Witness" is a Witness that can be instantiated anywhere within a package and guarantees provenance by wrapping the package ID.

In a package dependent on account.tech, such a module must be defined:

  • A Witness is defined for each package version, similar to the UpgradeCap version

  • The latest Witness is used in a current() package-only function that returns a VersionWitness

  • This type is then used in certain functions and checked against the Account dependencies

With this design, it is guaranteed that the VersionWitness for a given package can only be instantiated within that same package, effectively replicating the Witness pattern at the package level.

Last updated