It currently says that developers should use 'chelonia/contract/sync', but that's wrong, as they're supposed to use 'cheloina/contract/retain' along with 'chelonia/contract/release'.
A separate problem is this code inside of 'chelonia/contract/sync':
if (!forcedSync && this.subscriptionSet.has(contractID)) {
const rootState = sbp(this.config.stateSelector)
if (!rootState[contractID]?._volatile?.dirty) {
return sbp('chelonia/private/queueEvent', contractID, ['chelonia/private/noop'])
}
}
It's unclear to me what this code is doing, and it should be clearly commented.
Solution
Search the Group Income side of the app and replace all calls to 'chelonia/contract/sync' with 'chelonia/contract/retain' (and release).
Then anywhere the concept of resyncing a currently sync'd and retained contract is needed, either call a new selector (e.g. 'chelonia/contract/forceSync'), or change the behavior of 'chelonia/contract/sync' so that it does force syncing. Be careful if you pick the "change behavior" route, since if any old versions of contracts that call that expecting the old behavior to be there, then the behavior shouldn't be changed (since those are deployed for life now). My preference would be to change the behavior for 'chelonia/contract/sync', so that forceSync is true by default, and tell developers to call this on contracts upon logging in (or coming back online). Go through the app and search for places where we need to explicitly set forceSync: false.
Update the Information Flow section with the latest correct guidance (use retain most of the time, and sync upon login).
Problem
Our
Information-Flow.md
documentation is outdated for how to sync a contract.It currently says that developers should use
'chelonia/contract/sync'
, but that's wrong, as they're supposed to use'cheloina/contract/retain'
along with'chelonia/contract/release'
.A separate problem is this code inside of
'chelonia/contract/sync'
:It's unclear to me what this code is doing, and it should be clearly commented.
Solution
'chelonia/contract/sync'
with'chelonia/contract/retain'
(andrelease
).'chelonia/contract/forceSync'
), or change the behavior of'chelonia/contract/sync'
so that it does force syncing. Be careful if you pick the "change behavior" route, since if any old versions of contracts that call that expecting the old behavior to be there, then the behavior shouldn't be changed (since those are deployed for life now). My preference would be to change the behavior for'chelonia/contract/sync'
, so thatforceSync
istrue
by default, and tell developers to call this on contracts upon logging in (or coming back online). Go through the app and search for places where we need to explicitly setforceSync: false
.retain
most of the time, andsync
upon login).