Skip to content

Commit

Permalink
[release/4.x] Cherry pick: Simplify construction of JS globals (micro…
Browse files Browse the repository at this point in the history
…soft#5385) (microsoft#5736)

Co-authored-by: Eddy Ashton <[email protected]>
  • Loading branch information
achamayou and eddyashton authored Oct 17, 2023
1 parent 74b3481 commit 8ec47ab
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 400 deletions.
32 changes: 20 additions & 12 deletions src/apps/js_generic/js_generic_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,26 @@ namespace ccfapp
js::ReadOnlyTxContext historical_txctx{historical_tx};

js::register_request_body_class(ctx);
js::populate_global(
&txctx,
historical_tx ? &historical_txctx : nullptr,
endpoint_ctx.rpc_ctx.get(),
transaction_id,
receipt,
nullptr,
context.get_subsystem<ccf::AbstractHostProcesses>().get(),
nullptr,
&context.get_historical_state(),
this,
ctx);
js::init_globals(ctx);
js::populate_global_ccf_kv(&txctx, ctx);

if (historical_tx != nullptr)
{
CCF_ASSERT(
transaction_id.has_value(),
"Expected transaction_id to be passed with historical_tx");
CCF_ASSERT(
receipt != nullptr,
"Expected receipt to be passed with historical_tx");
js::populate_global_ccf_historical_state(
&historical_txctx, transaction_id.value(), receipt, ctx);
}

js::populate_global_ccf_rpc(endpoint_ctx.rpc_ctx.get(), ctx);
js::populate_global_ccf_host(
context.get_subsystem<ccf::AbstractHostProcesses>().get(), ctx);
js::populate_global_ccf_consensus(this, ctx);
js::populate_global_ccf_historical(&context.get_historical_state(), ctx);

js::JSWrappedValue export_func;
try
Expand Down
Loading

0 comments on commit 8ec47ab

Please sign in to comment.