types

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToQueryVesting = errors.Register(govtypes.ModuleName, 17, "failed to query vesting contract")
	ErrInvalidMetadata      = errors.Register(govtypes.ModuleName, 18, "invalid proposal or vote metadata")
)

NOTE: The latest version (v0.47.0) of the vanilla gov module already uses error codes 2-16, so we start from 17. https://github.com/cosmos/cosmos-sdk/blob/main/x/gov/types/errors.go

Functions

This section is empty.

Types

type CreatePosition

type CreatePosition struct {
	User         string    `json:"user"`
	VestSchedule *Schedule `json:"vest_schedule"`
}

CreatePosition corresponding to the Rust enum variant `mars_vesting::msg::ExecuteMsg::CreatePosition`

type ExecuteMsg

type ExecuteMsg struct {
	CreatePosition *CreatePosition `json:"create_position,omitempty"`
	Withdraw       *Withdraw       `json:"withdraw,omitempty"`
}

ExecuteMsg corresponding to the Rust enum `mars_vesting::msg::ExecuteMsg`

NOTE: For covenience, we don't include other enum variants, as they are not needed here.

type InstantiateMsg

type InstantiateMsg struct {
	Owner          string    `json:"owner"`
	UnlockSchedule *Schedule `json:"unlock_schedule"`
}

InstantiateMsg corresponding to the Rust type `mars_vesting::msg::InstantiateMsg`

type ProposalMetadata

type ProposalMetadata struct {
	Title             string   `json:"title"`
	Authors           []string `json:"authors,omitempty"`
	Summary           string   `json:"summary"`
	Details           string   `json:"details,omitempty"`
	ProposalForumURL  string   `json:"proposal_forum_url,omitempty"`
	VoteOptionContext string   `json:"vote_option_context,omitempty"`
}

ProposalMetadata defines the required schema for proposal metadata.

func UnmarshalProposalMetadata

func UnmarshalProposalMetadata(metadataStr string) (*ProposalMetadata, error)

UnmarshalProposalMetadata unmarshals a string into ProposalMetadata.

Golang's JSON unmarshal function doesn't check for missing fields. Instead, for example, if the "title" field here in ProposalMetadata is missing, the json.Unmarshal simply returns metadata.Title = "" instead of throwing an error.

Here's the equivalent Rust code for comparison, which properly throws an error is a required field is missing: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0e2eadad38b7cd212962b1a0e7a6da44

Therefore, we have to implement our own unmarshal function which checks for missing fields.

type QueryMsg

type QueryMsg struct {
	VotingPower  *VotingPowerQuery  `json:"voting_power,omitempty"`
	VotingPowers *VotingPowersQuery `json:"voting_powers,omitempty"`
}

QueryMsg corresponding to the Rust enum `mars_vesting::msg::QueryMsg`

NOTE: For covenience, we don't include other enum variants, as they are not needed here.

type Schedule

type Schedule struct {
	StartTime uint64 `json:"start_time"`
	Cliff     uint64 `json:"cliff"`
	Duration  uint64 `json:"duration"`
}

Schedule corresponding to the Rust type `mars_vesting::msg::Schedule`

type VoteMetadata

type VoteMetadata struct {
	Justification string `json:"justification,omitempty"`
}

VoteMetadata defines the required schema for vote metadata.

func UnmarshalVoteMetadata

func UnmarshalVoteMetadata(metadataStr string) (*VoteMetadata, error)

UnmarshalVoteMetadata unmarshals a string into VoteMetdata.

type VotingPowerQuery

type VotingPowerQuery struct {
	User string `json:"user,omitempty"`
}

VotingPowerQuery corresponding to the Rust enum variant `mars_vesting::msg::QueryMsg::VotingPower`

type VotingPowerResponse

type VotingPowerResponse struct {
	User        string    `json:"user"`
	VotingPower math.Uint `json:"voting_power"`
}

VotingPowerResponseItem corresponding to the `voting_powers` query's respons type's repeating element

type VotingPowersQuery

type VotingPowersQuery struct {
	StartAfter string `json:"start_after,omitempty"`
	Limit      uint32 `json:"limit,omitempty"`
}

VotingPowersQuery corresponding to the Rust enum variant `mars_vesting::msg::QueryMsg::VotingPowers`

type VotingPowersResponse

type VotingPowersResponse []VotingPowerResponse

VotingPowerResponse corresponding to the response type of the `voting_powers` query

type Withdraw

type Withdraw struct{}

Withdraw corresponding to the Rust enum variant `mars_vesting::msg::ExecuteMsg::Withdraw`

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL