Skip to content

Commit

Permalink
fix(circular import): remove utils from notices file since it causes …
Browse files Browse the repository at this point in the history
…a circular reference
  • Loading branch information
atticusofsparta committed Nov 13, 2024
1 parent 9d514a3 commit e9c8571
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/common/balances.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local balances = {}

--- Transfers the ANT to a specified wallet.
---@param to string - The wallet address to transfer the balance to.
---@return nil
---@return table<string, integer>
function balances.transfer(to)
utils.validateArweaveId(to)
Balances = { [to] = 1 }
Expand Down
26 changes: 21 additions & 5 deletions src/common/notices.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local json = require("json")
local utils = require(".common.utils")
local notices = {}

--- @param oldMsg AoMessage
Expand Down Expand Up @@ -40,9 +39,9 @@ function notices.debit(msg)
})
end

--- @param notices table<AoMessage>
function notices.sendNotices(notices)
for _, notice in ipairs(notices) do
--- @param noticesToSend table<AoMessage>
function notices.sendNotices(noticesToSend)
for _, notice in ipairs(noticesToSend) do
ao.send(notice)
end
end
Expand All @@ -57,10 +56,27 @@ function notices.notifyState(msg, target)
return
end

---@type AntState
local state = {
Records = Records,
Controllers = Controllers,
Balances = Balances,
Owner = Owner,
Name = Name,
Ticker = Ticker,
Logo = Logo,
Description = Description,
Keywords = Keywords,
Denomination = Denomination,
TotalSupply = TotalSupply,
Initialized = Initialized,
["Source-Code-TX-ID"] = SourceCodeTxId,
}

ao.send(notices.addForwardedTags(msg, {
Target = target,
Action = "State-Notice",
Data = json.encode(utils.getState()),
Data = json.encode(state),
}))
end

Expand Down
2 changes: 1 addition & 1 deletion src/common/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
--- Name: string,
--- Ticker: string,
--- Description: string,
--- Keywords: string,
--- Keywords: table<string>,
--- Logo: string,
--- Balances: table<string, integer>,
--- Owner: string,
Expand Down

0 comments on commit e9c8571

Please sign in to comment.