Got first token modules working, and a bunch of bugfixes throughout
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
--- tokenomics
|
||||
-- @module tokenomics
|
||||
-- Depends on consent
|
||||
|
||||
local tokenomics = {
|
||||
name = "Tokenomics",
|
||||
@ -50,10 +51,15 @@ function tokenomics:initiate(result)
|
||||
"consent",
|
||||
self.initiator,
|
||||
{
|
||||
prompt = "Create token "..self.token_slug.."?",
|
||||
prompt = "Create token "..
|
||||
self.config.token_slug.."?",
|
||||
votes_required = #self.org.members
|
||||
},
|
||||
function()
|
||||
modpol.interactions.message_org(
|
||||
self.initiator, self.org.id,
|
||||
"Consent reached: creating token "..
|
||||
self.config.token_slug)
|
||||
self:create_token()
|
||||
end
|
||||
)
|
||||
@ -65,11 +71,13 @@ end
|
||||
|
||||
function tokenomics:create_token()
|
||||
if not self.org.tokens then self.org.tokens = {} end
|
||||
self.org.tokens[slug] = self.config.token_variables
|
||||
self.org.tokens[self.config.token_slug] =
|
||||
self.config.token_variables
|
||||
self.org:record("Created token "..self.config.token_slug,
|
||||
self.slug)
|
||||
modpol.interactions.message_org(
|
||||
self.initiator, self.org.id,
|
||||
"Token "..self.config.token_slug.." created")
|
||||
-- TODO need to add to persistent storage?
|
||||
"Created token "..self.config.token_slug)
|
||||
if self.data.result then self.data.result() end
|
||||
-- call this wherever process might end:
|
||||
self.org:delete_process(self.id)
|
||||
@ -135,7 +143,7 @@ end
|
||||
function tokenomics.transfer(org, token, sender, recipient, amount)
|
||||
local sender_balance = tokenomics.balance(org, token, sender)
|
||||
local recipient_balance = tokenomics.balance(org, token, recipient)
|
||||
if not sender_balance or recipient balance then
|
||||
if not sender_balance or recipient_balance then
|
||||
return nil, "Transfer failed, user not found"
|
||||
else
|
||||
sender_balance = sender_balance - amount
|
||||
|
Reference in New Issue
Block a user