permaweb / aos

An operating system for AO: The hyper parallel computer
https://ao.g8way.io
Other
74 stars 52 forks source link

fix: variable clash with the process' global variable: 'Name' in the token blueprint #280

Closed hitwill closed 3 months ago

hitwill commented 4 months ago

Each process has a global var called Name, and this clashes with the token blueprint's Name variable.

The line: Name = Name or 'Points Coin' is never assigned, since Name already has the value of the process name. (Default or whatever the dev names it)

For example, the dev might name the process Currency Contract when instantiating it. In this case, the token never gets the name Points Coin.

This can be fixed by updating the line to: TokenName = TokenName or 'Points Coin'

twilson63 commented 3 months ago

I think it has to be Name possibly add better instructions for setting it when creating a token process

hitwill commented 3 months ago

I think it has to be Name possibly add better instructions for setting it when creating a token process

Perhaps one option is:

  1. Remove: Name = Name or 'Points Coin'
  2. Then in the Info handler, add this comment
--[[
     Info

     Note: token Name is inherited from the process name
   ]]
--

Handlers.add('info', Handlers.utils.hasMatchingTag('Action', 'Info'), function(msg)
  ao.send({
    Target = msg.From,
    Name = Name, 
    Ticker = Ticker,
    Logo = Logo,
    Denomination = tostring(Denomination)
  })
end)
hitwill commented 3 months ago

Closed as superseded by: https://github.com/permaweb/aos/pull/287