Skip to content

Commit

Permalink
Release #1 (#14)
Browse files Browse the repository at this point in the history
* Update README.md

* Added Royalty feature (#12)

* Fixed royalty and fee calculation in Offchain

* First release validator

* Martify Marketplace Validator
  • Loading branch information
AlainMgz authored Jan 2, 2022
1 parent bf867be commit 2f166d7
Show file tree
Hide file tree
Showing 17 changed files with 300 additions and 220 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A buyer can then unlock the NFT by submitting a transaction verifying the severa
* Go into the Martify repo after you built it using `cabal build`
* run `cabal run market-plutus`
* copy the resulting `market.plutus` file in the folder where you minted the NFT
* run `cabal run datum-json price sellerAddr tokenName policyId` where sellerAddr is the output you copied previously
* run `cabal run datum-json sellerAddr price tokenName policyId royaltyAddr royaltyPercent` where sellerAddr is the output you copied previously, royaltyAddr should also be hash address (if you don't know, just put the same as sellerAddr and 0 for royaltyPercent)
* copy the resulting file in the folder where you minted the NFT
* go back to the folder where you minted the NFT
* run `cardano-cli address build --payment-script-file market.plutus --$testnet >> script.addr`
Expand Down
8 changes: 5 additions & 3 deletions app/datum-json.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ import Market.Types (NFTSale(..))
-- Constructs the JSON file for the datum, used as input to --tx-in-datum-file in cardano-cli
main :: IO ()
main = do
[price', seller', tn' ,cs'] <- getArgs
[price', seller', tn' ,cs', raddr', rprct'] <- getArgs
let price = read price'
seller = fromString seller'
tn = fromString tn'
cs = fromString cs'
nftEx = NFTSale seller price cs tn
writeData ("datum-" ++ show cs ++ "-" ++ tn' ++ ".json") nftEx
raddr = fromString raddr'
rprct = read rprct'
nfts = NFTSale seller price cs tn raddr rprct
writeData ("datum-" ++ show cs ++ "-" ++ tn' ++ ".json") nfts
putStrLn "Done"
-- Datum also needs to be passed when sending the token to the script (aka putting for sale)
-- When doing this, the datum needs to be hashed, see Alonzo-purple exercise-solutions on how to hash a datum
Expand Down
8 changes: 4 additions & 4 deletions app/market-plutus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import Prelude
import System.Environment ( getArgs )
import qualified Data.ByteString.Short as SBS

import Market.Onchain (apiBuyScript, buyScriptAsShortBs)
import Utility (companyPkhReal)
import Market.Onchain as O2 (apiBuyScript, buyScriptAsShortBs)
import Utility (mpReal, mpMainnet)


main :: IO ()
main = do
args <- getArgs
let nargs = length args
let scriptnum = if nargs > 0 then read (head args) else 42
let scriptname = if nargs > 1 then args!!1 else "market.plutus"
let scriptname = if nargs > 1 then args!!1 else "market_mainnet_final.plutus"
putStrLn $ "Writing output to: " ++ scriptname
writePlutusScript scriptnum scriptname (apiBuyScript companyPkhReal) (buyScriptAsShortBs companyPkhReal)
writePlutusScript scriptnum scriptname (O2.apiBuyScript mpMainnet) (O2.buyScriptAsShortBs mpMainnet)


writePlutusScript :: Integer -> FilePath -> PlutusScript PlutusScriptV1 -> SBS.ShortByteString -> IO ()
Expand Down
100 changes: 55 additions & 45 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,48 @@ write-ghc-environment-files: never
tests: true
benchmarks: true

-- Plutus revision from 2021/12/06
source-repository-package
type: git
location: https://github.com/input-output-hk/plutus.git
location: https://github.com/input-output-hk/plutus-apps.git
subdir:
freer-extras
playground-common
plutus-chain-index
plutus-core
plutus-contract
plutus-chain-index
plutus-ledger
plutus-ledger-api
plutus-pab
plutus-tx
plutus-tx-plugin
plutus-use-cases
prettyprinter-configurable
quickcheck-dynamic
word-array
tag: plutus-starter-devcontainer/v1.0.11
tag: plutus-starter-devcontainer/v1.0.14


-- The following sections are copied from the 'plutus' repository cabal.project at the revision
-- The following sections are copied from the 'plutus-apps' repository cabal.project at the revision
-- given above.
-- This is necessary because the 'plutus' libraries depend on a number of other libraries which are
-- This is necessary because the 'plutus-apps' libraries depend on a number of other libraries which are
-- not on Hackage, and so need to be pulled in as `source-repository-package`s themselves. Make sure to
-- re-update this section from the template when you do an upgrade.

-- This is also needed so evenful-sql-common will build with a
-- newer version of persistent. See stack.yaml for the mirrored
-- configuration.
package eventful-sql-common
ghc-options: -XDerivingStrategies -XStandaloneDeriving -XUndecidableInstances -XDataKinds -XFlexibleInstances -XMultiParamTypeClasses
-- We never, ever, want this.
write-ghc-environment-files: never

-- Always build tests and benchmarks.
tests: true
benchmarks: true

-- The only sensible test display option
test-show-details: streaming

allow-newer:
-- Pins to an old version of Template Haskell, unclear if/when it will be updated
-- Copied from plutus-core
size-based:template-haskell
, ouroboros-consensus-byron:formatting
, beam-core:aeson
, beam-sqlite:aeson
, beam-sqlite:dlist
, beam-migrate:aeson

-- Copied from plutus-core
constraints:
-- big breaking change here, inline-r doens't have an upper bound
singletons < 3.0
Expand All @@ -58,10 +59,6 @@ constraints:
-- constraint from dependent-sum-template (which is the library we actually use).
, dependent-sum > 0.6.2.0

-- See the note on nix/pkgs/default.nix:agdaPackages for why this is here.
-- (NOTE this will change to ieee754 in newer versions of nixpkgs).
extra-packages: ieee, filemanip

-- These packages appear in our dependency tree and are very slow to build.
-- Empirically, turning off optimization shaves off ~50% build time.
-- It also mildly improves recompilation avoidance.
Expand All @@ -75,8 +72,7 @@ package ouroboros-consensus-cardano
package cardano-api
optimization: False

-- https://github.com/Quid2/flat/pull/22 fixes a potential exception
-- when decoding invalid (e.g. malicious) text literals.
-- Copied from plutus-core
source-repository-package
type: git
location: https://github.com/Quid2/flat.git
Expand All @@ -93,15 +89,17 @@ source-repository-package
location: https://github.com/input-output-hk/servant-purescript.git
tag: a0c7c7e37c95564061247461aef4be505a853538

-- Copied from plutus-core
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-crypto.git
tag: 07397f0e50da97eaa0575d93bee7ac4b2b2576ec

-- Copied from plutus-core
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 592aa61d657ad5935a33bace1243abce3728b643
tag: 4ea7e2d927c9a7f78ddc69738409a5827ab66b98
subdir:
base-deriving-via
binary
Expand All @@ -114,6 +112,7 @@ source-repository-package
slotting
strict-containers

-- Copied from plutus-core
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
Expand Down Expand Up @@ -143,10 +142,11 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 5d37a927046bc7da2887830d8e35cf604622ce09
tag: 1f4973f36f689d6da75b5d351fb124d66ef1057d
subdir:
monoidal-synchronisation
typed-protocols
typed-protocols-cborg
typed-protocols-examples
ouroboros-network
ouroboros-network-testing
Expand Down Expand Up @@ -186,32 +186,31 @@ source-repository-package

source-repository-package
type: git
location: https://github.com/raduom/cardano-ledger-specs
tag: ef6bb99782d61316da55470620c7da994cc352b2
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bf008ce028751cae9fb0b53c3bef20f07c06e333
subdir:
byron/chain/executable-spec
byron/crypto
byron/crypto/test
byron/ledger/executable-spec
byron/ledger/impl
byron/ledger/impl/test
semantics/executable-spec
cardano-ledger-core
cardano-protocol-tpraos
eras/alonzo/impl
eras/byron/chain/executable-spec
eras/byron/crypto
eras/byron/crypto/test
eras/byron/ledger/executable-spec
eras/byron/ledger/impl/test
eras/shelley/impl
eras/shelley-ma/impl
libs/non-integral
libs/small-steps
semantics/small-steps-test
shelley/chain-and-ledger/dependencies/non-integer
shelley/chain-and-ledger/executable-spec
shelley/chain-and-ledger/shelley-spec-ledger-test
shelley-ma/impl
cardano-ledger-core
alonzo/impl

-- A lot of plutus dependencies have to be synchronized with the dependencies of
-- A lot of plutus-apps dependencies have to be synchronized with the dependencies of
-- cardano-node. If you update cardano-node, please make sure that all dependencies
-- of cardano-node are also updated.
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-node.git
tag: ed7fdbf65f40f8e194850b87dd8c631fe26154e6
tag: b6ca519f97a0e795611a63174687e6bb70c9f752
subdir:
cardano-api
cardano-node
Expand All @@ -230,10 +229,21 @@ source-repository-package

source-repository-package
type: git
location: https://github.com/input-output-hk/hedgehog-extras
tag: edf6945007177a638fbeb8802397f3a6f4e47c14
location: https://github.com/input-output-hk/goblins
tag: cde90a2b27f79187ca8310b6549331e59595e7ba

-- A lot of plutus-apps dependencies have to be syncronized with the dependencies of
-- plutus. If you update plutus, please make sure that all dependencies of plutus
-- are also updated
source-repository-package
type: git
location: https://github.com/input-output-hk/goblins
tag: cde90a2b27f79187ca8310b6549331e59595e7ba
location: https://github.com/input-output-hk/plutus
tag: 3f089ccf0ca746b399c99afe51e063b0640af547
subdir:
plutus-core
plutus-ledger-api
plutus-tx
plutus-tx-plugin
word-array
prettyprinter-configurable
stubs/plutus-ghc-stub
2 changes: 1 addition & 1 deletion close.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"constructor":2,"fields":[]}
{"constructor":1,"fields":[]}
3 changes: 3 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ cradle:

- path: "./app/datum-json.hs"
component: "exe:datum-json"

- path: "./app/update-datum-json.hs"
component: "exe:update-datum-json"
Loading

0 comments on commit 2f166d7

Please sign in to comment.