Virtual File System

Username registration is currently disabled on mainnet.

Introduction

The Virtual File System (VFS) is a part of the Andromeda Messaging System (AMP) which was heavily inspired by the linux file system. Users can register their address to a username. They can also register ADOs to paths. These paths can then be used and referenced in our ADO systems.

When an Andromeda App is made, it will register all paths for its child components and also register itself as a child of the instantiating address. Each component under the App is registered by its name, and the App itself is registered under its assigned name.

In addition to paths, symbolic links that point to a path can be created by users.

All paths and usernames are resolved by the VFS in lowercase. For example, the username "USER" and "user" are considered to be the same. Same applies for paths, "/home/USERNAME" and "/home/username" are the same.

Example:

A user does the following:

  1. Registers their address as user1 by calling RegisterUser

  2. The user then creates an App and calls it "app-1" which has 2 compnents named "comp-1" and "comp-2"

  3. The App will automatically register its components under their assigned names

When you register a username, it will registered in the "home" directory.

The following paths are now registered:

  • /home/user1 will resolve the the user's address

  • /home/user1/app-1 is the path to get the address of the app contract

  • /home/user/app-1/comp-1 is the path to get the address of component 1 in the app

  • /home/user/app-1/comp-2 is the path to get the address of component 2 in the app

When Can we Use a VFS Path

When you go through our ADOs, you will notice an AndrAddr struct used very frequently for specifying addresses, whether be user addresses or ADO addresses. The use of this struct signifies that the address can be referenced by either the VFS path or the user/contract address. More on the AndrAddr struct can be found here.

VFS Paths in Apps

Local references can be used in case of Apps. These would include the component addresses and can be referenced using " ./<component-name>" as a valid path.

For example if I want to create an app with two components named "token" and "auction", and in the auction I want to reference the token address, I can use ./token to do so. Another example here would be a sending an NFT from a CW721 to an auction. Instead of specifying the auction contract address as the recipient, you can use the local reference ./auction to do so as long as the components belong to the same App.

Ado_type: vfs

InstantiateMsg

pub struct InstantiateMsg {
    pub kernel_address: String,
    pub owner: Option<String>,
}

ExecuteMsg

AddPath

Registers a component to the path.

Only accepts alphanumeric charaters.

If user1 registers ado1, then the path created would be /home/user1/ado1.

Registering a path that is already found will overwrite the old path.

pub enum ExecuteMsg {    
    AddPath {
        name: String,
        address: Addr,
        parent_address:Option<AndrAddr> 
    }
}

Creates a symbolic link that points to a specific path.

pub enum ExecuteMsg {
AddSymlink {
        name: String,
        symlink: AndrAddr,
        parent_address: Option<AndrAddr>,
    }
 }

In the JSON example above, if the username of the sender (parent address) is user1, then the symlink "/home/user1/my-link" would resolve to the path "/home/user2/app1".

RegisterUser

Registers a username to an address.

  • You can only register a username for your address (sender).

  • Only accepts alphanumeric charaters.

  • Usernames are unique, meaning no two users can have the same username.

  • If address is provided sender must be Kernel.

  • Username cannot exceed 40 characters.

  • This message is currently disabled on mainnet.

pub enum ExecuteMsg{
    RegisterUser {
        username: String,
        address: Option<Addr>,
        }
    }   

RegisterUserCrossChain

Registers the username of the sender on another chain.

Registerning a username on another chain needs to be done through the Andromeda chain first. Once the username is registered on the second chain, it is possible to register it to a third chain through Andromeda or the second chain.

For example, if I want to register my username on Juno and then Terra, I would need to call RegisterUserCrossChain message from the Andromeda chain FIRST specifying the chain field as juno. Once registered on Juno, I can call the message from either Andromeda or Juno to register it on Terra.

This message is currently disabled on mainnet.

pub enum ExecuteMsg {
  RegisterUserCrossChain {
        chain: String,
        address: String,
    },
 }

RegisterLibrary

Registers a library address under a library name. Libraries will be set up by Andromeda, and will contain a group of paths that resolve to addresses that can be used by users to create Apps. Users can use the SubDir query to get all the directories that are saved under the library name.

This message cannot be called by a user.

pub enum Execute {
 RegisterLibrary {
        lib_name: String,
        lib_address: Addr,
    }
}

AddChild

Registers the child's path relative to the parent.

Cannot be called by a user.

When Andromeda Apps are instantiated, it is automatically called, registering the App as a child to the sender's username and each of the components as children of the App itself similar to what we saw in the example above.

pub enum ExecuteMsg {
        AddParentPath {
        name: String,
        parent_address: AndrAddr,
    }
 }

Ownership

The set of ownerhsip messages. These messages are the same as the ones found in the ADO base section.

QueryMsg

ResolvePath

Gets the address of the specified path.

pub enum QueryMsg {
    #[returns(Addr)]
    ResolvePath { path: AndrAddr },
}

Returns the address of of the path. In the above JSON example, the address of ado2 would be returned.

SubDir

Gets all the paths under the specified directory. Min and max can be used for pagination.

pub enum QueryMsg {
  #[returns(Vec<PathDetails>)]
    SubDir {
        path: AndrAddr,
        min: Option<SubDirBound>,
        max: Option<SubDirBound>,
        limit: Option<u32>,
    }
 }

 pub struct SubDirBound {
    address: Addr,
    name: String,
}

PathDetails

Returns the path name and corresponding address for each subdirectory path.

pub struct PathDetails {
    name: String,
    address: Addr,
}

Paths

Gets all the paths that resolve to the specified address.

pub enum QueryMsg {
    #[returns(Vec<String>)]
    Paths { addr: Addr },
}

GetUsername

Gets the registered username of the specified address.

pub enum QueryMsg {
    #[returns(String)]
    GetUsername { address: Addr },
}

GetLibrary

Gets the library name of the specified library address.

pub enum QueryMsg {
    #[returns(String)]
    GetLibrary { address: Addr },
}

Returns the path that the specified symlink points to.

pub enum QueryMsg {
  #[returns(AndrAddr)]
   ResolveSymlink { path:AndrAddr },
 }

Version

Queries the version of the ADO.

pub enum AndromedaQuery {
     #[returns(VersionResponse)]
     Version {}
     }

VersionResponse

pub struct VersionResponse {
    pub version: String,
}

Owner

Queries the owner of the contract.

pub enum AndromedaQuery{
    #[returns(ContractOwnerResponse)]
    Owner{}
}

ContractOwnerResponse

pub struct ContractOwnerResponse {
    pub owner: String
}

Type

Queries the ADO type.

pub enum AndromedaQuery {
    #[returns(TypeResponse)]
    Type {}
}

TypeResponse

pub struct TypeResponse {
    pub ado_type: String,
    }

KernelAddress

Queries the kernel address of the chain the ADO is deployed on.

pub enum AndromedaQuery {
    #[returns(KernelAddressResponse)]
    KernelAddress {},
    }

Returns a String containing the contract address of the Kernel.

Last updated

Additional Resources

GithubWebsite