@@ -164,7 +164,9 @@ enforceDef = defNative "enforce" enforce
164
164
return (TLiteral (LBool True ) def)
165
165
else reduce msg >>= \ case
166
166
TLitString msg' -> failTx (_faInfo i) $ pretty msg'
167
- e -> evalError' i $ " Invalid message argument, expected string " <> pretty e
167
+ e -> isOffChainForkedError >>= \ case
168
+ OffChainError -> evalError' i $ " Invalid message argument, expected string " <> pretty e
169
+ OnChainError -> evalError' i $ " Invalid message argument, expected string, received argument of type: " <> pretty (typeof' e)
168
170
cond' -> reduce msg >>= argsError i . reverse . (: [cond'])
169
171
enforceLazy i as = mapM reduce as >>= argsError i
170
172
@@ -344,8 +346,11 @@ ifDef = defNative "if" if' (funType a [("cond",tTyBool),("then",a),("else",a)])
344
346
345
347
if' :: NativeFun e
346
348
if' i as@ [cond,then',else'] = gasUnreduced i as $ reduce cond >>= \ case
347
- TLiteral (LBool c') _ -> reduce (if c' then then' else else')
348
- t -> evalError' i $ " if: conditional not boolean: " <> pretty t
349
+ TLiteral (LBool c') _ -> reduce (if c' then then' else else')
350
+ t -> isOffChainForkedError >>= \ case
351
+ OffChainError -> evalError' i $ " if: conditional not boolean: " <> pretty t
352
+ OnChainError -> evalError' i $ " if: conditional not boolean, received value of type: " <> pretty (typeof' t)
353
+
349
354
if' i as = argsError' i as
350
355
351
356
@@ -529,8 +534,9 @@ defineNamespaceDef = setTopLevelOnly $ defGasRNative "define-namespace" defineNa
529
534
asBool =<< apply (App def' [] i) mkArgs
530
535
where
531
536
asBool (TLiteral (LBool allow) _) = return allow
532
- asBool t = evalError' fi $
533
- " Unexpected return value from namespace policy: " <> pretty t
537
+ asBool t = isOffChainForkedError >>= \ case
538
+ OffChainError -> evalError' fi $ " Unexpected return value from namespace policy: " <> pretty t
539
+ OnChainError -> evalError' fi $ " Unexpected return value from namespace policy, received value of type: " <> pretty (typeof' t)
534
540
535
541
mkArgs = [toTerm (asString nn),TGuard (_nsAdmin ns) def]
536
542
@@ -902,9 +908,12 @@ b = mkTyVar "b" []
902
908
c = mkTyVar " c" []
903
909
904
910
map' :: NativeFun e
905
- map' i as@ [tLamToApp -> TApp app _,l] = gasUnreduced i as $ reduce l >>= \ l' -> case l' of
911
+ map' i as@ [tLamToApp -> TApp app _,l] = gasUnreduced i as $ reduce l >>= \ case
906
912
TList ls _ _ -> (\ b' -> TList b' TyAny def) <$> forM ls (apply app . pure )
907
- t -> evalError' i $ " map: expecting list: " <> pretty (abbrev t)
913
+ t ->
914
+ isOffChainForkedError >>= \ case
915
+ OffChainError -> evalError' i $ " map: expecting list: " <> pretty (abbrev t)
916
+ OnChainError -> evalError' i $ " map: expecting list, received argument of type: " <> pretty (typeof' t)
908
917
map' i as = argsError' i as
909
918
910
919
list :: RNativeFun e
@@ -964,7 +973,10 @@ fold' :: NativeFun e
964
973
fold' i as@ [tLamToApp -> app@ TApp {},initv,l] = gasUnreduced i as $ reduce l >>= \ case
965
974
TList ls _ _ -> reduce initv >>= \ initv' ->
966
975
foldM (\ r a' -> apply (_tApp app) [r,a']) initv' ls
967
- t -> evalError' i $ " fold: expecting list: " <> pretty (abbrev t)
976
+ t ->
977
+ isOffChainForkedError >>= \ case
978
+ OffChainError -> evalError' i $ " fold: expecting list: " <> pretty (abbrev t)
979
+ OnChainError -> evalError' i $ " fold: expecting list, received argument of type: " <> pretty (typeof' t)
968
980
fold' i as = argsError' i as
969
981
970
982
@@ -977,7 +989,9 @@ filter' i as@[tLamToApp -> app@TApp {},l] = gasUnreduced i as $ reduce l >>= \ca
977
989
_ -> ifExecutionFlagSet FlagDisablePact420
978
990
(return False )
979
991
(evalError' i $ " filter: expected closure to return bool: " <> pretty app)
980
- t -> evalError' i $ " filter: expecting list: " <> pretty (abbrev t)
992
+ t -> isOffChainForkedError >>= \ case
993
+ OffChainError -> evalError' i $ " filter: expecting list: " <> pretty (abbrev t)
994
+ OnChainError -> evalError' i $ " filter: expecting list, received argument of type: " <> pretty (typeof' t)
981
995
filter' i as = argsError' i as
982
996
983
997
@@ -1084,8 +1098,9 @@ bind i as = argsError' i as
1084
1098
bindObjectLookup :: Term Name -> Eval e (Text -> Maybe (Term Name ))
1085
1099
bindObjectLookup (TObject (Object (ObjectMap o) _ _ _) _) =
1086
1100
return $ \ s -> M. lookup (FieldKey s) o
1087
- bindObjectLookup t = evalError (_tInfo t) $
1088
- " bind: expected object: " <> pretty t
1101
+ bindObjectLookup t = isOffChainForkedError >>= \ case
1102
+ OffChainError -> evalError (_tInfo t) $ " bind: expected object: " <> pretty t
1103
+ OnChainError -> evalError (_tInfo t) $ " bind: expected object, received value of type: " <> pretty (typeof' t)
1089
1104
1090
1105
typeof'' :: RNativeFun e
1091
1106
typeof'' _ [t] = return $ tStr $ typeof' t
@@ -1242,7 +1257,9 @@ concat' g i [TList ls _ _] = computeGas' g i (GMakeList $ fromIntegral $ V.lengt
1242
1257
concatTextList = flip TLiteral def . LString . T. concat
1243
1258
in fmap concatTextList $ forM ls' $ \ case
1244
1259
TLitString s -> return s
1245
- t -> evalError' i $ " concat: expecting list of strings: " <> pretty t
1260
+ t -> isOffChainForkedError >>= \ case
1261
+ OffChainError -> evalError' i $ " concat: expecting list of strings: " <> pretty t
1262
+ OnChainError -> evalError' i $ " concat: expected list of strings, received value of type: " <> pretty (typeof' t)
1246
1263
concat' _ i as = argsError i as
1247
1264
1248
1265
-- | Converts a string to a vector of single character strings
@@ -1375,6 +1392,7 @@ continueNested i as = gasUnreduced i as $ case as of
1375
1392
TDynamic tref tmem ti -> reduceDynamic tref tmem ti >>= \ case
1376
1393
Right d -> pure d
1377
1394
Left _ -> evalError' i $ " continue: dynamic reference did not point to Defpact"
1395
+ -- Note, pretty on `t` is not dangerous here, as it is not a reduced term.
1378
1396
_ -> evalError' i $ " continue: argument must be a defpact " <> pretty t
1379
1397
unTVar = \ case
1380
1398
TVar (Ref d) _ -> unTVar d
0 commit comments