dao

package module
v0.0.0-...-0234571 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 13 Imported by: 1

README

Quick Start

This folder/Go module is used for testing the DAO smart contracts and also serves as a primitive Go library for interacting with the DAO.

Recommended setup:

mkdir ~/dev/hypha && cd ~/dev/hypha
git clone https://github.com/hypha-dao/dao-contracts
cd dao-contracts
mkdir build
cmake ..
make -j8s
cd ../dao-go
go test -v -timeout 0

This file is used to start nodeos when running the Go tests. It should work if nodeos is in the path, but you should modify this to your environment.

dao-go/nodeos.sh : current contents

#!/bin/sh
nodeos -e -p eosio --plugin eosio::producer_plugin  --max-transaction-time 300 --plugin eosio::producer_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::http_plugin --plugin eosio::history_plugin --plugin eosio::history_api_plugin --filter-on='*' --access-control-allow-origin='*' --contracts-console --http-validate-host=false --verbose-http-errors --delete-all-blocks &> nodeos.log

Run tests

To run tests:

go test -v -timeout 0

NOTE: The test harness will start (and restart) your local instance of nodeos with the correct parameters as long as nodeos is in your path. This is used on macOS - see the nodeos.sh script and you may need to adapt for Windows or other environments.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPeriods

func AddPeriods(ctx context.Context, api *eos.API, daoContract eos.AccountName,
	predecessor eos.Checksum256,
	numPeriods int, periodDuration time.Duration) ([]docgraph.Document, error)

AddPeriods adds the number of periods with the corresponding duration to the DAO

func Apply

func Apply(ctx context.Context, api *eos.API, contract eos.AccountName,
	applicant eos.AccountName, notes string) (string, error)

Apply applies for membership to the DAO

func ClaimPay

func ClaimPay(ctx context.Context, api *eos.API, contract, claimer eos.AccountName, assignmentHash eos.Checksum256, periodID uint64) (string, error)

ClaimPay claims a period of pay for an assignment

func CloseProposal

func CloseProposal(ctx context.Context, api *eos.API, contract, closer eos.AccountName,
	proposalHash eos.Checksum256) (string, error)

CloseProposal ...

func CreateBallot

func CreateBallot(ctx context.Context, api *eos.API, telosDecide, creator eos.AccountName, ballotId string) (string, error)

func CreateOldAssignment

func CreateOldAssignment(t *testing.T, ctx context.Context, api *eos.API, contract, member eos.AccountName, memberDocHash, roleDocHash, startPeriodHash eos.Checksum256, assignment string) (docgraph.Document, error)

Creates an assignment without the INIT_TIME_SHARE, CURRENT_TIME_SHARE & LAST_TIME_SHARE nodes

func CreatePayout

func CreatePayout(ctx context.Context, api *eos.API,
	contract, telosDecide, proposer, recipient eos.AccountName,
	usdAmount eos.Asset, deferred int64, data []byte) (docgraph.Document, error)

CreatePayout ...

func CreatePretend

func CreatePretend(ctx context.Context, api *eos.API, contract, telosDecide, member eos.AccountName) (docgraph.Document, error)

CreatePretend ...

func CreateRoot

func CreateRoot(ctx context.Context, api *eos.API, contract eos.AccountName) (string, error)

CreateRoot creates the root node

func DefaultProgressBar

func DefaultProgressBar(counter int) *progressbar.ProgressBar

DefaultProgressBar ...

func DocumentVote

func DocumentVote(ctx context.Context, api *eos.API,
	contract, proposer eos.AccountName,
	badgeHash eos.Checksum256, notes string,
	startPeriod, endPeriod uint64) error

DocumentVote ....

func Enroll

func Enroll(ctx context.Context, api *eos.API, contract eos.AccountName, enroller, applicant eos.AccountName) (string, error)

Enroll an applicant in the DAO

func EnrollMembers

func EnrollMembers(ctx context.Context, api *eos.API, contract eos.AccountName)

EnrollMembers ...

func EraseAllDocuments

func EraseAllDocuments(ctx context.Context, api *eos.API, contract eos.AccountName)

EraseAllDocuments ...

func GetBalance

func GetBalance(ctx context.Context, api *eos.API, tokenContract, member string) eos.Asset

GetBalance return the token balance

func GetEscrowBalance

func GetEscrowBalance(ctx context.Context, api *eos.API, escrowContract, member string) eos.Asset

GetEscrowBalance returns the total amount locked in escrow for this user

func GetVotingPower

func GetVotingPower(ctx context.Context, api *eos.API, telosDecide, voter eos.AccountName) eos.Asset

GetVotingPower ...

func InitTD

func InitTD(ctx context.Context, api *eos.API, telosDecide eos.AccountName) (string, error)

InitTD ...

func Issue

func Issue(ctx context.Context, api *eos.API, token, issuer eos.AccountName, amount eos.Asset) (string, error)

Issue ...

func IssueHVoice

func IssueHVoice(ctx context.Context, api *eos.API, contract, auth eos.AccountName,
	to eos.AccountName, quantity eos.Asset) (string, error)

func MigrateHVoice

func MigrateHVoice(ctx context.Context, api *eos.API, contract, daoContract eos.AccountName, trailContract eos.AccountName) (string, error)

func Mint

func Mint(ctx context.Context, api *eos.API, telosDecide, issuer, receiver eos.AccountName, amount eos.Asset) (string, error)

Mint ...

func NewTreasury

func NewTreasury(ctx context.Context, api *eos.API, telosDecide, treasuryManager eos.AccountName) (string, error)

NewTreasury ...

func OpenBallot

func OpenBallot(ctx context.Context, api *eos.API, telosDecide, creator eos.AccountName, ballotId string, expiration int) (string, error)

func ProposalVote

func ProposalVote(
	ctx context.Context, api *eos.API,
	contract, voter eos.AccountName,
	vote string, proposalHash eos.Checksum256, notes string) (string, error)

ProposalVote

func ProposalVoteWithoutNotes

func ProposalVoteWithoutNotes(
	ctx context.Context, api *eos.API,
	contract, voter eos.AccountName,
	vote string, proposalHash eos.Checksum256) (string, error)

ProposalVote

func Propose

func Propose(ctx context.Context, api *eos.API,
	contract, proposer eos.AccountName, proposal Proposal) (string, error)

Propose ...

func ProposeAssExtension

func ProposeAssExtension(ctx context.Context, api *eos.API,
	contract, proposer eos.AccountName, assignmentHash string, additionalPeriods int) (string, error)

func ProposeAssignment

func ProposeAssignment(ctx context.Context, api *eos.API,
	contract, proposer, assignee eos.AccountName,
	roleHash, startPeriod eos.Checksum256, assignment string) (string, error)

ProposeAssignment creates a proposal for an new assignment

func ProposeBadge

func ProposeBadge(ctx context.Context, api *eos.API, contract, proposer eos.AccountName, content string) (string, error)

ProposeBadge proposes the badge to the specified DAO contract

func ProposeBadgeAssignment

func ProposeBadgeAssignment(ctx context.Context, api *eos.API,
	contract, proposer, assignee eos.AccountName,
	badgeHash, startPeriod eos.Checksum256, assignment string) (string, error)

ProposeBadgeAssignment proposes the badge assignment to the specified DAO contract

func ProposeEdit

func ProposeEdit(ctx context.Context, api *eos.API,
	contract, proposer eos.AccountName, original docgraph.Document, edit string) (string, error)

ProposeEdit creates an edit proposal

func ProposePayout

func ProposePayout(ctx context.Context, api *eos.API,
	contract, proposer, recipient eos.AccountName,
	usdAmount eos.Asset, deferred int64, payout string) (string, error)

ProposePayout ...

func ProposePayoutWithPeriod

func ProposePayoutWithPeriod(ctx context.Context, api *eos.API,
	contract, proposer, recipient eos.AccountName, endPeriod eos.Checksum256,
	usdAmount eos.Asset, deferred int64, payout string) (string, error)

ProposePayoutWithPeriod creates a proposal for an new payout/contribution

func ProposeRole

func ProposeRole(ctx context.Context, api *eos.API,
	contract, proposer eos.AccountName, role string) (string, error)

ProposeRole creates a proposal for an new assignment

func RegVoter

func RegVoter(ctx context.Context, api *eos.API, telosDecide, registrant eos.AccountName) (string, error)

RegVoter ...

func RemSetting

func RemSetting(ctx context.Context, api *eos.API, contract eos.AccountName, settingAtt string) (string, error)

RemSetting ...

func ReplaceContent2

func ReplaceContent2(groups []docgraph.ContentGroup, label string, value *docgraph.FlexValue) error

func SetAssetSetting

func SetAssetSetting(ctx context.Context, api *eos.API, contract eos.AccountName, label string, value eos.Asset) (string, error)

func SetIntSetting

func SetIntSetting(ctx context.Context, api *eos.API, contract eos.AccountName, label string, value int64) (string, error)

SetIntSetting is a helper for setting a single name type configuration item

func SetNameSetting

func SetNameSetting(ctx context.Context, api *eos.API, contract eos.AccountName, label string, value eos.AccountName) (string, error)

SetNameSetting is a helper for setting a single name type configuration item

func SetSetting

func SetSetting(ctx context.Context, api *eos.API, contract eos.AccountName, configAtt string, flexValue *docgraph.FlexValue) (string, error)

SetSetting sets a single attribute on the configuration

func SetupCreateAssignment

func SetupCreateAssignment(ctx context.Context, api *eos.API, contract, telosDecide, member eos.AccountName, parentType, assignmentType eos.Name, data []byte) (docgraph.Document, error)

CreateAssignment ...

func SetupCreateBadge

func SetupCreateBadge(ctx context.Context, api *eos.API, contract, telosDecide, member eos.AccountName, data []byte) (docgraph.Document, error)

CreateBadge ...

func SetupCreateRole

func SetupCreateRole(ctx context.Context, api *eos.API, contract, telosDecide, member eos.AccountName, data []byte) (docgraph.Document, error)

CreateRole ...

func TelosDecideVote

func TelosDecideVote(ctx context.Context, api *eos.API,
	telosDecide, voter eos.AccountName, ballot,
	passFail eos.Name) (string, error)

TelosDecideVote ...

func Transfer

func Transfer(ctx context.Context, api *eos.API, token, from, to eos.AccountName, amount eos.Asset, memo string) (string, error)

Transfer ...

func TransferHVoice

func TransferHVoice(ctx context.Context, api *eos.API, contract, auth eos.AccountName,
	from eos.AccountName, to eos.AccountName, quantity eos.Asset) (string, error)

func UpdateAssignments

func UpdateAssignments(ctx context.Context, api *eos.API, contract eos.AccountName) error

func UpdatePeriods

func UpdatePeriods(ctx context.Context, api *eos.API, contract eos.AccountName) error

UpdatePeriods ...

func VotePass

func VotePass(ctx context.Context, api *eos.API, contract,
	telosDecide, voter eos.AccountName, proposal *docgraph.Document) (string, error)

Types

type Account

type Account struct {
	Balance         eos.Asset  `json:"balance"`
	LastDecayPeriod eos.Uint64 `json:"last_decay_period"`
}

func GetMemberHVoiceAccount

func GetMemberHVoiceAccount(ctx context.Context, api *eos.API, contract, memberAccount eos.AccountName) (Account, error)

type CloseDocProp

type CloseDocProp struct {
	ProposalHash eos.Checksum256 `json:"proposal_hash"`
}

CloseDocProp is closing proposals for document proposals

type IssueHVoiceArgs

type IssueHVoiceArgs struct {
	To       eos.AccountName
	Quantity eos.Asset
	Memo     string
}

type Lock

type Lock struct {
	ID            uint64             `json:"id"`
	LockType      eos.Name           `json:"lock_type"`
	Sponsor       eos.Name           `json:"sponsor"`
	Beneficiary   eos.Name           `json:"beneficiary"`
	Quantity      eos.Asset          `json:"quantity"`
	TriggerEvent  eos.Name           `json:"trigger_event"`
	TriggerSource eos.Name           `json:"trigger_source"`
	VestingDate   eos.BlockTimestamp `json:"vesting_date"`
	Notes         string             `json:"notes"`
	CreatedDate   eos.BlockTimestamp `json:"created_date"`
	UpdatedDate   eos.BlockTimestamp `json:"updated_date"`
}

Lock is an escrow lock

type MigrateHVoiceArgs

type MigrateHVoiceArgs struct {
	DaoContract   eos.AccountName
	TrailContract eos.AccountName
}

type Period

type Period struct {
	PeriodID  uint64             `json:"period_id"`
	StartTime eos.BlockTimestamp `json:"start_date"`
	EndTime   eos.BlockTimestamp `json:"end_date"`
	Phase     string             `json:"phase"`
}

Period represents a period of time aligning to a payroll period, typically a week

type Proposal

type Proposal struct {
	Proposer      eos.AccountName         `json:"proposer"`
	ProposalType  eos.Name                `json:"proposal_type"`
	ContentGroups []docgraph.ContentGroup `json:"content_groups"`
}

Proposal is a document to be proposed

type QrAction

type QrAction struct {
	Timestamp      time.Time `json:"@timestamp"`
	TrxID          string    `json:"trx_id"`
	ActionContract string
	ActionName     string
	Data           string
}

QrAction ...

type Scope

type Scope struct {
	Code  eos.Name `json:"code"`
	Scope eos.Name `json:"scope"`
	Table eos.Name `json:"table"`
	Payer eos.Name `json:"payer"`
	Count uint64   `json:"count"`
}

Scope ...

type SeedsExchConfigTable

type SeedsExchConfigTable struct {
	SeedsPerUsd   eos.Asset `json:"seeds_per_usd"`
	TlosPerUsd    eos.Asset `json:"tlos_per_usd"`
	CitizenLimit  eos.Asset `json:"citizen_limit"`
	ResidentLimit eos.Asset `json:"resident_limit"`
	VisitorLimit  eos.Asset `json:"visitor_limit"`
}

SeedsExchConfigTable ...

type SeedsPriceHistory

type SeedsPriceHistory struct {
	ID       uint64        `json:"id"`
	SeedsUSD eos.Asset     `json:"seeds_usd"`
	Date     eos.TimePoint `json:"date"`
}

SeedsPriceHistory ...

type Stats

type Stats struct {
	Supply         eos.Asset       `json:"supply"`
	MaxSupply      eos.Asset       `json:"max_supply"`
	Name           eos.AccountName `json:"name"`
	DecayPerPeriod string          `json:"decay_per_period"`
	DecayPeriod    eos.Uint64      `json:"last_decay_period"`
}

func GetHvoiceIssued

func GetHvoiceIssued(ctx context.Context, api *eos.API, contract eos.AccountName, symbol eos.Symbol) (Stats, error)

type TransferHVoiceArgs

type TransferHVoiceArgs struct {
	From     eos.AccountName
	To       eos.AccountName
	Quantity eos.Asset
	Memo     string
}

type Vote

type Vote struct {
	Voter      eos.AccountName `json:"voter"`
	BallotName eos.Name        `json:"ballot_name"`
	Options    []eos.Name      `json:"options"`
}

Vote represents a set of options being cast as a vote to Telos Decide

type VoteProposal

type VoteProposal struct {
	Voter        eos.AccountName `json:"voter"`
	ProposalHash eos.Checksum256 `json:"proposal_hash"`
	Vote         string          `json:"vote"`
	Notes        string          `json:"notes"`
}

VoteProposal votes for a proposal (native ballot)

Jump to

Keyboard shortcuts

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