-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Offchain implementation of SmartToken contracts (#13)
* Initial nix and server boilerplate * Offchain protocol params and directory * Programmable Transfer * Module refactoring, rebase & formatting * Add endpoint for deploying protocol params * Add loadEnv * Fill directory derivation and redeemers * Add test * Programmable token issue tx builder * Seizing tx builder * Add initDirectoryTx + test (failing in lib/SmartTokens/LinkedList/Common.hs:214) * Initial builders for transfer contracts * Fix 'initDirectoryTx' * Make a single endpoint for deployment * Add some query endpoints * Better type for query result * Wst.Offchain.Endpoints.Env -> Wst.Offchain.Env, rename to OperatorEnv * Move all env-like types to Wst.Offchain.Env * Use classes for environment bits * Use Env in DirectorySet, move Query module around * Add InsertNodeArgs for insertDirectoryNode * Issue transfer logic builder * Add TransferLogicEnv * Fix insert directory node test * Add transferStablecoins tx builder * Add seizeStablecoins tx builder * Add issueProgrammableTokenTx endpoint * Export issueProgrammableTokenTx * issueProgrammableTokenTx with always yields validator * Add query for programmable logic UTxOs * CLI command parser * CLI setup * Load operator files * Add some documentation * Link to linked list * Typo * Add server implementation, better handling of Environment * WIP issue and transfer smart tokens endpoints * Smart token transfer unit test flow * Sezing endpoint/unit test & fixes to transfer * Error handling for blacklisted node * Fix alwaysSucceeds script * Update hash --------- Co-authored-by: Jann Müller <[email protected]>
- Loading branch information
Showing
44 changed files
with
2,997 additions
and
302 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Main where | ||
|
||
import Wst.Cli qualified | ||
|
||
main :: IO () | ||
main = Wst.Cli.runMain |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module SmartTokens.CodeLens( | ||
_printTerm | ||
) where | ||
|
||
import Data.Text qualified as T | ||
import GHC.Stack (HasCallStack) | ||
import Plutarch (ClosedTerm) | ||
import Plutarch.Internal qualified as PI | ||
import Plutarch.Internal.Other (printScript) | ||
|
||
-- TODO: Move to catalyst-libs project | ||
|
||
-- _printTerm (communicated by Philip) just print some term as string. The term we want to print is | ||
-- @ | ||
-- _term :: forall {s :: S}. Term s PBlacklistNode | ||
-- _term = unsafeEvalTerm NoTracing (pconstant $ BlackListNode { key = "a", next = "b" }) | ||
-- @ | ||
-- Below, we inline the term and have it in a code lens. You can even run the code lens via Haskell | ||
-- language server. The lens will then replace the string starting with "program ..." with exactly | ||
-- the same string. | ||
-- | ||
-- >>> _printTerm (pconstantData $ BlacklistNode { blnKey = "a hi", blnNext = "a" }) | ||
-- "program 1.0.0 (List [B #61206869, B #61])" | ||
_printTerm :: HasCallStack => ClosedTerm a -> String | ||
_printTerm term = printScript $ either (error . T.unpack) id $ PI.compile PI.NoTracing term |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{-| Plutus V3 script that always yields, ignoring its argument | ||
-} | ||
module SmartTokens.Contracts.AlwaysYields( | ||
palwaysSucceed | ||
) where | ||
|
||
import Plutarch.LedgerApi.V3 (PScriptContext) | ||
import Plutarch.Prelude (ClosedTerm, PUnit, pconstant, plam, (:-->)) | ||
|
||
{-| Validator that always succeeds | ||
-} | ||
palwaysSucceed :: ClosedTerm (PScriptContext :--> PUnit) | ||
palwaysSucceed = plam (const $ pconstant ()) |
This file contains 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
Oops, something went wrong.