Skip to content

Commit

Permalink
Fix error messages display
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudip Bhattarai committed Feb 20, 2023
1 parent 5b74acd commit e456782
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 45 deletions.
64 changes: 32 additions & 32 deletions playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions playground/src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ import { callKuber,getPolicyIdOfScriptFromKuber,listProviders, signTx, submitTx
scale="1.2"
/>
</div>
<div class="flex w-full px-4 py-8 2xl:text-base xl:text-sm lg:text-sm">
<div class="flex w-full 2xl:text-base xl:text-sm lg:text-sm">
<!-- Address utitlity -->
<AddressUtil v-if="utility == UtilitiesEnums.Address"></AddressUtil>
<!-- Script Utilities -->
<div
class="flex w-full flex-col items-start"
class="flex w-full flex-col items-start px-4 py-8"
v-if="utility == UtilitiesEnums.ScriptHash"
>
<div class="mb-5 font-semibold text-gray-500">Enter script json</div>
Expand Down Expand Up @@ -430,7 +430,7 @@ import { callKuber,getPolicyIdOfScriptFromKuber,listProviders, signTx, submitTx

<!-- Hex Utility -->
<div
class="flex flex-col w-full items-center"
class="flex flex-col w-full items-center px-4 py-8"
v-if="utility == UtilitiesEnums.Hex"
>
<div class="flex flex-col items-start w-full relative">
Expand Down Expand Up @@ -1226,9 +1226,7 @@ export default {
request.collaterals = collateral;
}
if (this.addSelections) {
console.log("Adding selections")
const availableUtxos = await instance.getUtxos();
console.log('after getUtxos')
if (request.selections) {
if (typeof request.selections.push === "function") {
availableUtxos.forEach((v) => {
Expand All @@ -1242,7 +1240,6 @@ export default {
request.selections = availableUtxos;
}
}
console.log("calling kuber")
let url =this.activeApi.url
if(!url && this.activeApi.name=='Auto'){
const network=await instance.getNetworkId()
Expand All @@ -1262,8 +1259,15 @@ export default {
const signedTx= await signTx (instance,transactionResponse.tx)
const signedTxHex=signedTx.to_hex()
this.kuberOutputs.push("Signed Tx : ["+(signedTxHex.length /2) +" bytes] " + signedTxHex)
submitTx(instance,signedTx)
this.kuberOutputs.push("Tx Submitted ✓✓")
return submitTx(instance,signedTx).then(()=>{
this.kuberOutputs.push("Tx Submitted ✓✓")
}).catch(e=>{
this.kuberOutputs.push("❌ Tx submission Failed: " +((e && (e.message || e.info)) || e))
notification.setNotification({
type: "error",
message: ((e && (e.message || e.info)) ) || "Oopsie, Nobody knows what happened",
});
})
})
.catch((e: any) => {
Expand Down
12 changes: 7 additions & 5 deletions src/Cardano/Kuber/Core/TxFramework.hs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ txBuilderToTxBody' dCinfo@(DetailedChainInfo cpw conn pParam ledgerPParam syste
Nothing -> pure $ Right $ transform (policy,f)
Just eu -> pure $ Left $ transform (policy, f eu)
TxMintingReferenceScript ti m_eu m_sd -> case Map.lookup ti mp of
Nothing -> Left $ FrameworkError BalancingError "Reference Script Utxo is missing"
Nothing -> Left $ FrameworkError BalancingError $ "Reference Script Utxo is missing :" ++ T.unpack ( renderTxIn ti)
Just (TxOut _ _ _ (ReferenceScript _ anySc@(ScriptInAnyLang sl sc'))) ->do
ScriptInEra langInEra script' <- validateScriptSupportedInEra' BabbageEra anySc
case script' of
Expand Down Expand Up @@ -410,7 +410,7 @@ txBuilderToTxBody' dCinfo@(DetailedChainInfo cpw conn pParam ledgerPParam syste
txContextCollaterals =foldl getCollaterals [] _collaterals
getCollaterals accum x = case x of
TxCollateralTxin txin -> accum++ (case Map.lookup txin availableUtxo of
Nothing -> error "Collateral input missing in utxo map"
Nothing -> error $ "Collateral input missing in utxo map : " ++ T.unpack ( renderTxIn txin)
Just (TxOut a v dh _) -> case addressInEraToPaymentKeyHash a of
Just pkh -> (txin,pkh) : accum
Nothing -> error "Invalid address type utxo in collateral"
Expand Down Expand Up @@ -459,7 +459,9 @@ txBuilderToTxBody' dCinfo@(DetailedChainInfo cpw conn pParam ledgerPParam syste

monadFailChangeAddr= case mChangeAddr of
Nothing -> if null usableAddresses
then Left $ FrameworkError BalancingError "no change address"
then if null _inputs && null selections
then Left $ FrameworkError BalancingError "No utxo available for fee payment: both `inputs` and `selections` are empty"
else Left $ FrameworkError BalancingError "Change address is missing"
else pure $ head usableAddresses

Just aie -> pure aie
Expand Down Expand Up @@ -657,11 +659,11 @@ txBuilderToTxBody' dCinfo@(DetailedChainInfo cpw conn pParam ledgerPParam syste
TxInputReferenceScriptUtxo scriptRefTin mData r mExunit (UTxO txin) -> mapM (\(_in,val) -> do
exUnit <- getExUnit _in mExunit
case Map.lookup scriptRefTin availableUtxo of
Nothing -> Left $ FrameworkError LibraryError "Missing utxo for reference script"
Nothing -> Left $ FrameworkError LibraryError $ "Missing reference script utxo: " ++ T.unpack (renderTxIn scriptRefTin)
Just (TxOut _ _ _ (ReferenceScript _ (ScriptInAnyLang sl sc))) ->do
witness <- createTxInReferenceScriptWitness scriptRefTin Nothing mData r exUnit
pure (_in,Right (mExunit, witness,val ))
Just _ ->Left $ FrameworkError BalancingError "Reference script utxo doesn't contain reference script"
Just _ ->Left $ FrameworkError BalancingError $ "Utxo used as refreence script doesn't contain reference script: " ++ T.unpack (renderTxIn scriptRefTin)
) $ Map.toList txin

where
Expand Down

0 comments on commit e456782

Please sign in to comment.