Documentation
¶
Index ¶
- Variables
- func CreateHomeDir() error
- func DeleteKeyFromBucket(key int, bucketName []byte) error
- func FlushDB() error
- func InitUSStates() map[int]string
- func NewRequest(request ConnectRequest) error
- func OpenDB() (*bolt.DB, error)
- func Populate()
- func Save(dir string, bucketName []byte, x BucketItem) error
- func UpdateAsset(key int, info Asset) error
- func UpdatePledge(key int, updated Pledge) error
- type Actor
- type Asset
- type BucketItem
- type Certificate
- type City
- type ClimateReport
- type Company
- func NewCompany(name string, country string) (Company, error)
- func RetrieveAllCompanies() ([]Company, error)
- func RetrieveAllMultiNationals() ([]Company, error)
- func RetrieveCompany(key int) (Company, error)
- func RetrieveCompanyByName(name string, country string) (Company, error)
- func SearchCompany(name string) ([]Company, error)
- func (c *Company) AddAssets(assetIDs ...int) error
- func (c *Company) AddCountries(countryIDs ...int) error
- func (c *Company) AddPledges(pledgeIDs ...int) error
- func (c *Company) AddRegions(regionIDs ...int) error
- func (c *Company) AddStates(stateIDs ...int) error
- func (c *Company) GetAssetsByState(state string) ([]Asset, error)
- func (c *Company) GetCountries() ([]Country, error)
- func (x *Company) GetID() int
- func (c Company) GetPledges() ([]Pledge, error)
- func (c *Company) GetRegions() ([]Region, error)
- func (c *Company) GetStates() ([]State, error)
- func (x *Company) Save() error
- func (x *Company) SetID(id int)
- func (c *Company) UpdateMRV(MRV string)
- type ConnectRequest
- type Country
- type DistributionRecord
- type EthWallet
- type Location
- type Oversight
- type Pledge
- type Region
- type ReportsByYear
- type State
- func FilterStatesByCountry(country string) ([]State, error)
- func NewState(name string, country string) (State, error)
- func RetrieveAllStates() ([]State, error)
- func RetrieveState(key int) (State, error)
- func RetrieveStateByName(name string, country string) (State, error)
- func SearchState(name string) ([]State, error)
- type User
- func NewUser(username string, pwhash string, email string, entityType string, ...) (User, error)
- func RetrieveAllUsers() ([]User, error)
- func RetrieveUser(key int) (User, error)
- func RetrieveUserByUsername(username string) (User, error)
- func ValidateAccessToken(username string, accessToken string) (User, error)
- func ValidateUser(username string, pwhash string) (User, error)
- func (u *User) AddPledge(pledge Pledge)
- func (a *User) GenAccessToken() (string, error)
- func (a *User) GenEthKeys(seedpwd string) error
- func (x *User) GetID() int
- func (user *User) RetrieveUserEntity() (Actor, error)
- func (x *User) Save() error
- func (a *User) SendEthereumTx(address string, amount big.Int) (string, error)
- func (x *User) SetID(id int)
Constants ¶
This section is empty.
Variables ¶
var AssetBucket = []byte("Assets")
var CityBucket = []byte("Cities")
var CompanyBucket = []byte("Companies")
var CountryBucket = []byte("Countries")
var CountryIds map[int]string
var OversightBucket = []byte("Oversight")
var PledgeBucket = []byte("Pledges")
var RegionBucket = []byte("Regions")
var RequestBucket = []byte("Requests")
var StateBucket = []byte("States")
var USStateCities map[string][]string
var USStates []string
var UserBucket = []byte("Users")
Functions ¶
func DeleteKeyFromBucket ¶
DeleteKeyFromBucket deletes a given key from the bucket bucketName but doesn not shift indices of elements succeeding the deleted element's index
func InitUSStates ¶
func NewRequest ¶
func NewRequest(request ConnectRequest) error
func UpdateAsset ¶
func UpdatePledge ¶
Types ¶
type Actor ¶
type Asset ¶
type Asset struct {
Index int
Title string
Subtitle string
CompanyID int
Name string
Location string
State string
Type string
ActionType []string
Capacity float64
Reports []ReportsByYear
}
func RetrieveAllAssets ¶
RetrieveAllAssets gets a list of all assets in the database
func RetrieveAsset ¶
Given a key of type int, retrieves the corresponding asset object from the database assets bucket.
func RetrieveAssetByName ¶
Given a name and company, retrieves the corresponding asset object from the database assets bucket.
func (*Asset) ReportAssetData ¶
type BucketItem ¶
type Certificate ¶
type City ¶
type City struct {
// Identifying info
Index int
Name string
Region string
Country string
// Contextual data
Area float64
Iso string
Population int
Latitude float64
Longitude float64
Revenue float64
CompanySize int
HQ string
MRV string
Children []string
Pledges []int
Emissions map[string]string // accept whatever emissions the frontend passes
Mitigation map[string]string
Adaptation map[string]string
LastUpdated string
}
Our definition of "City" includes cities, municipalities, towns, shires, villages, communes, etc. The following struct defines the relevant fields.
func NewCity ¶
Function that creates a new city object given its name, region, and country and saves the object in the countries bucket.
func RetrieveAllCities ¶
Retrieves all countries from the countries bucket.
func RetrieveCity ¶
Given a key of type int, retrieves the corresponding city object from the database cities bucket.
func RetrieveCityByName ¶
Given a name and region, retrieves the corresponding city object from the database cities bucket.
func SearchCity ¶
func (*City) AddPledges ¶
func (City) GetPledges ¶
type ClimateReport ¶
type Company ¶
type Company struct {
// Identifying info
Index int
Name string `json:"shortname"`
FullName string `json:"name"`
Description string `json:"description"`
Locations []Location `json:"locations"`
Accountability []DistributionRecord `json:"accountability"`
Country string
Address string
UserIDs []int
// Contextual data
Area float64
Iso string
Population int
// Latitude float64
// Longitude float64
Revenue float64
CompanySize int
HQ string
MultiNational []string // an array of all the countries a company is in; if not an MNC, leave empty
ForProfit bool
Industry bool
MRV string // the company's chosen MRV reporting methodology
Pledges []int
// Nested scopes
States []int
Regions []int
Countries []int
// The entity IDs of all the company's physical assets
Assets []int
// IDs of all the company's financial/regulatory assets (e.g. RECs, climate bonds, etc.)
Certificates []Certificate
ClimateReports []ClimateReport
LastUpdated string
Files []string // list of ipfs hashes to be stored for verification or something similar
}
Our definition of "Company" includes .... The following struct defines the relevant fields.
func NewCompany ¶
Function that creates a new company object given its name and country and saves the object in the countries bucket.
func RetrieveAllCompanies ¶
RetrieveAllCompanies gets a list of all companies in the database
func RetrieveCompany ¶
Given a key of type int, retrieves the corresponding company object from the database companies bucket.
func RetrieveCompanyByName ¶
Given a name and country, retrieves the corresponding company object from the database companies bucket.
func SearchCompany ¶
func (*Company) AddCountries ¶
func (*Company) AddPledges ¶
func (*Company) AddRegions ¶
func (*Company) GetAssetsByState ¶
func (*Company) GetCountries ¶
func (*Company) GetID ¶
BucketItem interface method:
A getter method for structs that implement the BucketItem interface. The method allows you to retrieve the ID of structs that implement the BucketItem interface methods, even if you don't know specifically which struct you are workign with.
func (Company) GetPledges ¶
func (*Company) GetRegions ¶
func (*Company) SetID ¶
BucketItem interface method:
SetID() is a common method between all structs that qualify as bucket items that allow them to implement the BucketItem interface. SetID() is a simple setter method that allows the updating of the bucket item's ID. The function's only use should be in the Save() function; otherwise, the ID should not be modified.
type ConnectRequest ¶
type ConnectRequest struct {
Index int
DBName string
OrgName string
DBActorTypes []string // what type of actors does the DB cover?
DBActionTypes []string // what type of actions does the DB track?
ContactInfo string
Links []string // links with more info
}
func RetrieveAllRequests ¶
func RetrieveAllRequests() ([]ConnectRequest, error)
func (*ConnectRequest) GetID ¶
func (x *ConnectRequest) GetID() int
func (*ConnectRequest) Save ¶
func (x *ConnectRequest) Save() error
func (*ConnectRequest) SetID ¶
func (x *ConnectRequest) SetID(id int)
type Country ¶
type Country struct {
// Identifying info
Index int
Name string `json:"name"`
FullName string `json:"full_name"`
Description string `json:"description"`
// Contextual data
Area float64
Iso string
Population int
Latitude float64
Longitude float64
Revenue float64
CompanySize int
HQ string
MRV string
// For countries: children = regions
Children []string
Credits []int
Pledges []int `json:"pledges"`
Logo string `json:"logo"`
Accountability []DistributionRecord `json:"accountability"`
Emissions map[string]string `json:"emissions"` // accept whatever emissions data the frontend passes
Mitigation map[string]string
Adaptation map[string]string
LastUpdated string
Files []string // an a rray of all the necessary documents to validate this specific country
}
Nation-states, countries
func NewCountry ¶
Function that creates a new country object given its name and saves the object in the countries bucket.
func RetrieveAllCountries ¶
Retrieves all countries from the countries bucket.
func RetrieveCountry ¶
Given a key of type int, retrieves the corresponding country object from the database countries bucket.
func RetrieveCountryByName ¶
Given the name of the country, retrieves the corresponding country object from the database countries bucket.
func (*Country) AddPledges ¶
func (Country) GetPledges ¶
type DistributionRecord ¶
type Oversight ¶
type Oversight struct {
Index int
Name string
UserIDs []int
// options:
// - "international organization"
// - "UNFCCC Body"
// - "Civil Society"
// - "Financial Institution"
// - "Research Organization"
// - "Independent Reviewer"
// - "Oracle System"
OrgType string
MRV string
Scope string // where does the actor operate?
Weight int // their weight, based on the organization's reputation
}
func RetrieveAllOsOrgs ¶
func RetrieveOsOrg ¶
func RetrieveOsOrgByName ¶
func (*Oversight) AddPledges ¶
func (Oversight) GetPledges ¶
type Pledge ¶
type Pledge struct {
ID int
ActorType string
ActorID int
Coop bool
/*
Pledges can be:
emissions reductions,
mitigation actions (energy efficiency, renewables, etc.),
or adaptation actions
*/
PledgeType string
BaseYear float64
TargetYear float64
Goal float64
// is this goal determined by a regulator, or voluntarily
// adopted by the climate actor?
Regulatory bool
}
func RetrieveAllPledges ¶
func RetrievePledge ¶
type Region ¶
type Region struct {
// Identifying info
Index int
Name string
Country string
// Contextual data
Area float64
Iso string
Population int
Latitude float64
Longitude float64
Revenue float64
CompanySize int
HQ string
MRV string
Pledges []int
// For regions: children = companies (divided by region)
Children []string
Emissions map[string]string // accept whatever emissions the frontend passes
Mitigation map[string]string
Adaptation map[string]string
LastUpdated string
}
Our definition of "Region" includes regions, areas, etc. The following struct defines the relevant fields.
func NewRegion ¶
Function that creates a new region object given its name and country and saves the object in the regions bucket.
func RetrieveAllRegions ¶
Retrieves all regions from the regions bucket.
func RetrieveRegion ¶
Given a key of type int, retrieves the corresponding region object from the database regions bucket.
func RetrieveRegionByName ¶
Given the name and country of the region, retrieves the corresponding region object from the database regions bucket.
func SearchRegion ¶
func (*Region) AddPledges ¶
func (Region) GetPledges ¶
type ReportsByYear ¶
type State ¶
type State struct {
// Identifying info
Index int
Name string
Country string
// Contextual data
Area float64
Iso string
Population int
Latitude float64
Longitude float64
Revenue float64
CompanySize int
HQ string
MRV string
Pledges []int
// For states: children = companies (divided by state)
Children []string
Emissions map[string]string // accept whatever emissions the frontend passes
Mitigation map[string]string
Adaptation map[string]string
LastUpdated string
Files []string
}
Our definition of "State" includes states, provinces, prefectures, etc. The following struct defines the relevant fields.
func FilterStatesByCountry ¶
Retrieves and filters state by country.
func NewState ¶
Function that creates a new state object given its name and country and saves the object in the states bucket.
func RetrieveAllStates ¶
Retrieves all states from the states bucket.
func RetrieveState ¶
Given a key of type int, retrieves the corresponding state object from the database states bucket.
func RetrieveStateByName ¶
Given the name and country of the state, retrieves the corresponding state object from the database states bucket.
func SearchState ¶
func (*State) AddPledges ¶
func (State) GetPledges ¶
type User ¶
type User struct {
Index int
FirstName string
LastName string
Username string
Email string
Pwhash string
EIN string
AccessToken string // the access token used to authenticate with the platform for future requests
EntityType string // choices are: individual, company, city, state, region, country, oversight
EntityID int // index of the entity the user is associated with
Verified bool // if the user is a verified member of the entity they purport to be a part of
Admin bool // is the user an admin for its entity?
EthereumWallet EthWallet
Liked []string // array of liked projects
NotVisible []string // array of visible projects
}
func NewUser ¶
func NewUser(username string, pwhash string, email string, entityType string, entityName string, entityParent string) (User, error)
NewUser creates a new user
func RetrieveAllUsers ¶
func RetrieveUser ¶
RetrieveUser retrieves a particular User indexed by key from the database
func RetrieveUserByUsername ¶
func ValidateAccessToken ¶
func ValidateUser ¶
ValidateUser validates a particular user