UNPKG

@mora-light/core

Version:
60 lines (47 loc) 1.79 kB
'use strict'; require('@dfinity/agent'); require('@dfinity/principal'); var running = require('./running-e74432b2.cjs.dev.js'); var types_transform_dist_moraLightCoreTypesTransform = require('../types/transform/dist/mora-light-core-types-transform.cjs.dev.js'); // transmits 2 - show data for user const doTransmitShow = async (transmit, runtime, running$1) => { // 0. return err if there is error message if (runtime.err !== undefined) { transmit.view.runtime = runtime; return; } // console.error("check candid value 0", JSON.stringify(transmit), JSON.stringify(runtime.ok)); // 1. fetch child type let { value } = running.findChildTypeAndValue(runtime.ok, transmit.from, transmit.child); // console.error("check candid value 1", JSON.stringify(runtime), JSON.stringify(value)); // 2. do transform const transformResult = await types_transform_dist_moraLightCoreTypesTransform.doTransform(transmit.transform, value, running$1); if (transformResult.err !== undefined) { transmit.view.runtime = transformResult; return; } value = transformResult.ok; // console.error( // "check candid value 2", // transmit.constraint.need, // JSON.stringify(value), // JSON.stringify(runtime), // checkCandidValue(transmit.constraint.need, value), // ); // 3. check value and type // if (!checkCandidValue(transmit.constraint.need, value, [])) { // transmit.constraint.runtime = { // err: `wrong value ${JSON.stringify(value)} for type '${unwrapCandidType( // transmit.constraint.need, // )}'`, // }; // return; // } // console.error("check candid value set", value); transmit.view.runtime = { ok: value }; }; exports.doTransmitShow = doTransmitShow;