Added LDoc comments for new files, ready to merge pt. 2
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
--- tokenomics
|
||||
-- @module tokenomics
|
||||
--- Tokenomics.
|
||||
-- Depends on consent
|
||||
-- @module tokenomics
|
||||
|
||||
local tokenomics = {
|
||||
name = "Tokenomics",
|
||||
@ -9,14 +9,11 @@ local tokenomics = {
|
||||
hide = true;
|
||||
}
|
||||
|
||||
--- (Required) Data for module
|
||||
-- Variables that module uses during the course of a process
|
||||
-- Can be blank
|
||||
tokenomics.data = {
|
||||
result = nil
|
||||
}
|
||||
|
||||
--- (Required): config for module
|
||||
--- Config for module
|
||||
-- @field consent Require consent to create?
|
||||
-- @field token_variables the data that goes into the token
|
||||
-- @field token_slug A no-spaces slug for the token
|
||||
@ -33,11 +30,11 @@ tokenomics.config = {
|
||||
}
|
||||
}
|
||||
|
||||
--- (Required): initiate function: creates a token in an org
|
||||
-- set up the token data structure
|
||||
-- create an org treasury
|
||||
--- Initiate function: creates a token in an org.
|
||||
-- Set up the token data structure.
|
||||
-- Create an org treasury
|
||||
-- @function tokenomics:initiate
|
||||
-- @param result (optional) Callback if this module is embedded in other modules
|
||||
-- @function initiate
|
||||
function tokenomics:initiate(result)
|
||||
-- TODO need to create a series of interactions to get the info from users
|
||||
self.data.result = result
|
||||
@ -69,6 +66,8 @@ function tokenomics:initiate(result)
|
||||
end
|
||||
end
|
||||
|
||||
--- Create token
|
||||
-- @function tokenomics:create_token
|
||||
function tokenomics:create_token()
|
||||
if not self.org.tokens then self.org.tokens = {} end
|
||||
self.org.tokens[self.config.token_slug] =
|
||||
@ -89,8 +88,9 @@ end
|
||||
-- all need to write to persistent data
|
||||
-- amount can be positive or negative (except transfer)
|
||||
|
||||
-- returns balance
|
||||
-- if no user, get treasury balance
|
||||
--- Returns balance.
|
||||
-- If no user, get treasury balance
|
||||
-- @function tokenomics.balance
|
||||
-- @param org Name (string) or id (num)
|
||||
-- @param token Slug (string)
|
||||
-- @param user Name (string)
|
||||
@ -112,8 +112,12 @@ function tokenomics.balance(org, token, user)
|
||||
end
|
||||
end
|
||||
|
||||
--- Change balance
|
||||
-- @function tokenomics.change_balance
|
||||
-- @param org Org name (string) or id (number)
|
||||
-- @param token Token slug (string)
|
||||
-- @param user
|
||||
-- @param amount
|
||||
function tokenomics.change_balance(org, token, user, amount)
|
||||
local this_org = modpol.orgs.get_org(org)
|
||||
if not this_org then
|
||||
@ -139,6 +143,12 @@ function tokenomics.change_balance(org, token, user, amount)
|
||||
end
|
||||
end
|
||||
|
||||
--- Transfer tokens from a sender to recipient
|
||||
-- @function tokenomics.transfer
|
||||
-- @param org
|
||||
-- @param token
|
||||
-- @param sender
|
||||
-- @param recipient
|
||||
-- @param amount Positive number
|
||||
function tokenomics.transfer(org, token, sender, recipient, amount)
|
||||
local sender_balance = tokenomics.balance(org, token, sender)
|
||||
@ -161,6 +171,11 @@ function tokenomics.transfer(org, token, sender, recipient, amount)
|
||||
end
|
||||
end
|
||||
|
||||
--- Transfer from treasury
|
||||
-- @function tokenomics.treasury_transfer
|
||||
-- @param org
|
||||
-- @param token
|
||||
-- @param recipient
|
||||
-- @param amount Can be positive or negative, assumes flow from treasury to recipient
|
||||
function tokenomics.treasury_transfer(org, token, recipient, amount)
|
||||
local this_org = modpol.orgs.get_org(org)
|
||||
@ -189,7 +204,11 @@ function tokenomics.treasury_transfer(org, token, recipient, amount)
|
||||
end
|
||||
end
|
||||
|
||||
-- creates new tokens in the org treasury
|
||||
--- Creates new tokens in the org treasury
|
||||
-- @function tokenomics.issue
|
||||
-- @param org
|
||||
-- @param token
|
||||
-- @param amount
|
||||
function tokenomics.issue(org, token, amount)
|
||||
local this_org = modpol.orgs.get_org(org)
|
||||
if not this_org then
|
||||
@ -209,5 +228,4 @@ end
|
||||
|
||||
------------------------------------------
|
||||
|
||||
--- (Required) Add to module table
|
||||
modpol.modules.tokenomics = tokenomics
|
||||
|
Reference in New Issue
Block a user