refactor: add id to each message
I recommend viewing the diff with indentation changes hidden
Clean up:
- chmod -x files in
assemblythat aren't executable - rename
PostedMessagetoMessage - make
describe...itstatements read more clearly
Add id:
- create id using
ulidlibrary on the frontend - add new
PersistentOrderedMapin the contract- uses a
PersistentVectorand aPersistentMapin tandem - provides limited functionality for upserting (insert or update) and other functionality that was needed by the existing app
- uses a
- only store new id field in
messages, not in each individual Message- saves gas & storage rent costs, since ids are stored only once
- somewhat complicates the interface, since we need to return maps instead of arrays
This lays the groundwork for doing optimistic UI updates, such as those being explored in #79
The failed Travis tests seem to actually be real failures this time.
@mikedotexe yes, they are – we either need the ability to serialize AssemblyScript Maps to JSON objects, or we need to make getMessages return an array of arrays. Then this will actually work. I've marked as draft for now until I have time to come back and wrap this up.
What is the status of this? @chadoh
@AnaisUrlichs this needs to be refactored to use PersistentUnorderedMap from near-sdk-as, added in https://github.com/near/near-sdk-as/pull/85
A bigger discussion is if we want this for the Guest Book demo. Two competing goals:
- We want demos that are easy for newbies to understand
- We want demos that make a good starting point for real apps
This works toward Goal 2, somewhat at the expense of Goal 1. What do you think?