From bea42e519ea3212ef9f8701c97644ff5294e6632 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 11 Dec 2024 09:42:21 +0100 Subject: [PATCH] wip on prefab implementation --- src/popls/bp.rs | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/popls/bp.rs b/src/popls/bp.rs index a5d2dce0..4857c33c 100644 --- a/src/popls/bp.rs +++ b/src/popls/bp.rs @@ -35,8 +35,8 @@ use bp::seals::TxoSeal; use bp::{dbc, Outpoint, Txid, Vout}; use commit_verify::CommitId; use hypersonic::{ - AdaptedState, AuthToken, CellAddr, CodexId, ContractId, IssueParams, MethodName, NamedState, - Operation, Schema, StateAtom, Supply, + AdaptedState, AuthToken, CallParams, CellAddr, CodexId, ContractId, CoreParams, DataCell, + IssueParams, MethodName, NamedState, Operation, Schema, StateAtom, Supply, }; use strict_encoding::{StrictDeserialize, StrictSerialize}; use strict_types::StrictVal; @@ -213,7 +213,43 @@ impl< /// Creates a single operation basing on the provided construction parameters. pub fn prefab(&self, params: ConstructParams) -> Prefab { // convert ExecParams into CallParams - todo!() + + let owned = params + .owned + .into_iter() + .map(|(seal, val)| { + let state = DataCell { + data: val.state, + auth: seal, + lock: None, + }; + NamedState { + name: val.name, + state, + } + }) + .collect(); + + let call = CallParams { + core: CoreParams { + method: params.method, + global: params.global, + owned, + }, + using: params.using, + reading: params.reading, + }; + + let stockpile = self.mound.contract(params.contract_id); + let opid = stockpile.stock().call(call); + let operation = stockpile.stock().operation(opid); + + Prefab { + contract_id: params.contract_id, + closes, + defines, + operation, + } } /// Completes creation of a prefabricated operation pack, adding blank operations if necessary.