Graph

Introduction

The Graph ADO allows users to construct a customized graphs. The user first specifies the configurations of the graph at instantiation. Then they are able to store coordinates for points on the graph. These saved points can then be fetched by using the ADO's queries.

The graph can be a 3D graph (x,y, and z coordinates) or a 2D graph (x,y coordinates only).

This ADO can also save and fetch points stored in the Point ADO.

Ado_type: cw721

Version: 0.1.0

InstantiateMsg

pub struct InstantiateMsg {
    pub map_info: MapInfo,
    pub kernel_address: String,
    pub owner: Option<String>,
}
Name
Type
Description

map_info

Specifies the configurations of the map.

kernel_address

String

Contract address of the kernel contract to be used for AMP messaging. Kernel contract address can be found in our deployed contracts.

owner

Option<String>

Optional address to specify as the owner of the ADO being created. Defaults to the sender if not specified.

MapInfo

#[cw_serde]
pub struct MapInfo {
    pub map_size: MapSize,
    pub allow_negative: bool,
    pub map_decimal: u16,
}
Name
Type
Description

map_size

Specifies the size of the map.

allow_negative

bool

Whether negative values can be assigned to points of the map. In case negative is allowed, the width of the axis is divided between the positive and negative halfs. For example if negative is allowed and the x_width is set as 1000, then the the x coordinate range is between -500 and 500.

map_decimal

u16

The max number of decimal points that can be specified for a point. For example, if the x_coordinate is set as 4.12345 and the map_decimal is set as 2, then the x coordinate is taken as 4.12 only.

MapSize

#[cw_serde]
pub struct MapSize {
    pub x_width: u64,
    pub y_width: u64,
    pub z_width: Option<u64>,
}
Name
Type
Description

x_width

u64

The maximum allowed x coordinate for the map.

y_width

u64

The maximum allowed y coordinate for the map.

z_width

Option<u64>

The maximum allowed z coordinate for the map. Can be ommited in case a 2D map is wanted by the user.

ExecuteMsg

UpdateMap

Update the map configurations set at instantiation.

Only available to the contract owner.

pub enum ExecuteMsg {
    UpdateMap {
        map_info: MapInfo,
    },
 }
Name
Type
Description

map_info

Specifies the configurations of the map.

StoreCoordinate

Stores the coordinates of a point on the map.

Only available to the contract owner.

pub enum ExecuteMsg {
    StoreCoordinate {
        coordinate: Coordinate,
        is_timestamp_allowed: bool,
        }
 }
Name
Type
Description

coordinate

The coordinates of the point.

is_timestamp_allowed

bool

Whether to store the timestamp that the point was created. If yes, then it would show along with the coordinates when queried.

Coordinate

#[cw_serde]
pub struct Coordinate {
    pub x_coordinate: f64,
    pub y_coordinate: f64,
    pub z_coordinate: Option<f64>,
}
Name
Type
Description

x_coordinate

f64

The x coordinate for the point.

y_coordinate

f64

The y coordinate for the point.

z_coordinate

Option<f64>

The z coordinate for the point. Do not specify in case the map is 2D (Only x and y).

StoreUserCoordinate

Store the coordinates from the specified Point ADO addresses.

pub enum ExecuteMsg {
 StoreUserCoordinate {
        user_location_paths: Vec<AndrAddr>,
    },
 }
Name
Type
Description

user_location_paths

Vec<AndrAddr>

A vector containing the addresses of the point ADOs.

DeleteUserCoordinate

Deletes the coordinate set for the specified point in the Point ADO.

pub enum ExecuteMsg {
 DeleteUserCoordinate {
        user: AndrAddr,
    },
 }
Name
Type
Description

user

AndrAddr

The Point ADO contract address to remove.

Base Executes

The rest of the execute messages can be found in the ADO Base section.

QueryMsg

GetMapInfo

Queries the map configurations set at instantiation.

pub enum QueryMsg {
    #[returns(GetMapInfoResponse)]
    GetMapInfo {},
    }

GetMapInfoResponse

#[cw_serde]
pub struct GetMapInfoResponse {
    pub map_info: MapInfo,
}

Returns a MapInfo struct.

GetMaxPointNumber

Queries the total number of points created.

pub enum QueryMsg {
    #[returns(GetMaxPointNumberResponse)]
    GetMaxPointNumber {},
    }

GetMaxPointResponse

#[cw_serde]
pub struct GetMaxPointNumberResponse {
    pub max_point: u128,
}
Name
Type
Description

max_point

u128

The total number of points created on the graph.

GetAllPoints

Queries all the created points, fetching their coordinates and timestamps if enabled.

pub enum QueryMsg {
 #[returns(GetAllPointsResponse)]
    GetAllPoints {
        start: Option<u128>,
        limit: Option<u32>,
   },
}
Name
Type
Description

start

Option<u128>

Optional point to start from. Used for pagination.

limit

Option<u32>

Optional limit on the number of results to return. Used for pagination.

GetAllPointsResponse

#[cw_serde]
pub struct GetAllPointsResponse {
    pub points: Vec<(CoordinateInfo, StoredDate)>,
}

#[cw_serde]
pub struct CoordinateInfo {
    pub x: String,
    pub y: String,
    pub z: Option<String>,
}

#[cw_serde]
pub struct StoredDate {
    pub timestamp: Option<u64>,
}

Returns a vector containing the coordinates of each point. Points that had timestamp enabled will have the timestamp returned as well.

GetUserCoordinate

Fetches the coordinate saved for the specified Point ADO.

pub enum QueryMsg { 
 #[returns(CoordinateInfo)]
    GetUserCoordinate { user: AndrAddr },
    }
Name
Type
Description

user

AndrAddr

The address of the Point ADO to fetch the poin coordinates for.

Returns an instance of CoordinateInfo.

Base Queries

The rest of the query messages can be found in the ADO Base section.

Last updated