CCF icon indicating copy to clipboard operation
CCF copied to clipboard

Expose governance-only JS API in ccf-app package

Open letmaik opened this issue 4 years ago • 2 comments

The new JS governance makes use of some new native functions exposed in the ccf global that are only available in the constitution, not in app endpoints:

  • ccf.network.getLatestLedgerSecretSeqno
  • ccf.node.triggerLedgerRekey
  • ccf.node.transitionServiceToOpen
  • ccf.node.triggerRecoverySharesRefresh
  • ccf.setJwtPublicSigningKeys, ccf.removeJwtPublicSigningKeys (those are currently also available in endpoints but are effectively useless there since endpoints don't have permission to write to gov tables)

I propose that such functions are added to the global module of ccf-app with notes that they are not available in endpoints. This has two purposes: documentation and allowing them to be used in npm-based TypeScript constitutions. The latter is possible with the same workflow used when writing apps with the difference that rollup must be configured to bundle everything in a single JS file (since JS governance does not support storing/importing separate modules).

EDIT: The only minor concern I have is that ccf-app was meant for apps only, but maybe the scope could be widened to any JavaScript that runs inside CCF.

letmaik avatar Apr 08 '21 16:04 letmaik

Sounds good to me!

achamayou avatar Apr 14 '21 19:04 achamayou

@letmaik another possibility would be to start ccf-gov, adding this functionality to ccf-app and perhaps also including some of the unit testing code for constitutions we've discussed a couple of times already.

achamayou avatar Nov 16 '22 21:11 achamayou