Skip to content

Commit

Permalink
wip on prefab implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 11, 2024
1 parent 1ad416a commit bea42e5
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions src/popls/bp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit bea42e5

Please sign in to comment.