Created
April 4, 2019 08:12
-
-
Save krisajenkins/5a69ca4b8483159f3f7d7f502bb31d5c to your computer and use it in GitHub Desktop.
Plutus Playground Smart Contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Contract endpoints that generate different kinds of errors for the log: | |
-- logAMessage produces a log message from a wallet | |
-- submitInvalidTxn submits an invalid txn which should result in a "Validation failed" message | |
-- throwWalletAPIError throws an error from a wallet (client) | |
import qualified Data.Set as Set | |
import Data.Text (Text) | |
import Ledger | |
import qualified Ledger.Ada as Ada | |
import Ledger.Validation | |
import Wallet | |
import Playground.Contract | |
logAMessage :: MonadWallet m => m () | |
logAMessage = logMsg "wallet log" | |
submitInvalidTxn :: MonadWallet m => m () | |
submitInvalidTxn = do | |
logMsg "Preparing to submit an invalid transaction" | |
let tx = Tx | |
{ txInputs = Set.empty | |
, txOutputs = [] | |
, txForge = Ada.adaValueOf 2 | |
, txFee = 0 | |
, txValidRange = defaultSlotRange | |
} | |
submitTxn tx | |
throwWalletAPIError :: MonadWallet m => Text -> m () | |
throwWalletAPIError = throwOtherError | |
$(mkFunctions ['logAMessage, 'submitInvalidTxn, 'throwWalletAPIError]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[0,[{"wallets":[{"simulatorWalletWallet":{"getWallet":2},"simulatorWalletBalance":{"getValue":[[0,50],[1,20],[2,20]]}},{"simulatorWalletWallet":{"getWallet":3},"simulatorWalletBalance":{"getValue":[[0,50],[1,20],[2,20]]}}],"signatures":[{"functionName":"logAMessage","argumentSchema":[]},{"functionName":"submitInvalidTxn","argumentSchema":[]},{"functionName":"throwWalletAPIError","argumentSchema":[{"tag":"SimpleStringSchema"}]},{"functionName":"payToPublicKey_","argumentSchema":[{"contents":[["ivTo",{"contents":[["getSlot",{"tag":"SimpleIntSchema"}]],"tag":"SimpleObjectSchema"}],["ivFrom",{"contents":[["getSlot",{"tag":"SimpleIntSchema"}]],"tag":"SimpleObjectSchema"}]],"tag":"SimpleObjectSchema"},{"contents":[["getValue",{"contents":[["unMap",{"contents":{"contents":[{"tag":"SimpleIntSchema"},{"tag":"SimpleIntSchema"}],"tag":"SimpleTupleSchema"},"tag":"SimpleArraySchema"}]],"tag":"SimpleObjectSchema"}]],"tag":"SimpleObjectSchema"},{"contents":[["getPubKey",{"tag":"SimpleIntSchema"}]],"tag":"SimpleObjectSchema"}]}],"actions":[{"blocks":10,"tag":"Wait"}]}]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment