permaweb / aos

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

chg(Assign): refactor Assign to use `ao.addAssignable` if self is included in the Assign Message #306

Closed twilson63 closed 2 months ago

twilson63 commented 3 months ago

Background

ao.assignables was added in a recent release of aos and allows specifying allow-disallow rules pertaining to assignments.

By default, all assignments are not trusted.

Problem

If a user assigns a message to this process, then they must also add a MatchSpec to ao.assignables. Otherwise, the assignment will not be trusted.

This is a disjointed two step process.

Solution

If the user uses Assign to assign a message to this process, then add the MessageId to the ao.assignables table.

if Utils.includes(ao.id, o.Processes) then
  ao.addAssignable("Allow-" .. o.Message, { Id = o.Message })
end
...