Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
701c6c5
Rewriting 'Mint you own NFT' in script, update readme.
Jun 10, 2022
7cb4fe9
Add base image for nft-market-place (fix ssl problem)
Jun 21, 2022
18b272d
Update nft-marketplace to the dev version
Jun 22, 2022
04e02d1
Fix frontend build scripts
nrutledge Jun 22, 2022
660e936
Minor fixes
Jun 23, 2022
3ed0664
Update nft-marketplace-server, CTL, ODC version (correct work with mi…
Jun 24, 2022
60c6a99
Temporal rollback ODC on non-master version.
Jun 28, 2022
514a0bf
Fix mint-nft.sh. Bump plutus-use-cases and seabug-contract.
Jun 30, 2022
167f300
Fix CTL initialization
Jul 1, 2022
fa4937d
Rename ctl.localho.st to ctl.localho.st, add ctl.localho.st domain.
Jul 1, 2022
6ad09dd
Fix CORS problem by nginx configuration.
Jul 1, 2022
8208690
Bump CTL to v2.0.0-alpha and update node config
Jul 5, 2022
992cfa4
Remove old testnet-config
Jul 5, 2022
bb4da7a
Update cardano-node (flake and arion), gmios, seabug-contract and plu…
Jul 8, 2022
6d8fce3
Fix restart policy for arion-compose
Jul 8, 2022
d81ca27
Update flake.lock
Jul 8, 2022
b94bbf0
Update testnet configuration (vasil hardfork)
Jul 8, 2022
e69e4b9
Update README.md
ryukzak Jul 10, 2022
617f0df
Bump dependencies
Jul 10, 2022
a33db0a
Add MINT-POLICY arg for mint-nft.sh. Update README.md
Jul 10, 2022
1b305e1
Update arion-compose.nix for new server version
rynoV Jul 23, 2022
e1ec944
Fix `nft-marketplace-server` setup
t4ccer Jul 23, 2022
16e90e3
Fix but this time for real
t4ccer Jul 25, 2022
b8a5e1c
Update plutus-use-cases to `t4/testnet-script`
rynoV Jul 27, 2022
3ace383
Update readme to inform about outdated minting scripts
rynoV Jul 27, 2022
b1a80ed
Minor fixes to arion-compose.nix
rynoV Jul 27, 2022
b92239e
Update CTL to version used by `seabug-contracts`
rynoV Jul 27, 2022
f8db84b
Merge branch 'aleksandr/bump-nftmarketplace' into calum/update-nft-ma…
rynoV Jul 27, 2022
48923cd
Merge pull request #21 from mlabs-haskell/calum/update-nft-marketplac…
rynoV Jul 27, 2022
3ec2e9d
Update `seabug-contracts`
rynoV Jul 27, 2022
961ef55
Update `nft-marketplace`
rynoV Jul 27, 2022
dfaedae
Update `nft-marketplace-server` to `main`
rynoV Jul 27, 2022
3398d17
Fix nginx to work with react-router
rynoV Jul 28, 2022
dde76dc
Rename cardano node config json file
rynoV Jul 28, 2022
1dfe8ea
Extract marketplace escrow address to constant
rynoV Jul 28, 2022
43dad7d
Remove broken parts of `mint-nft.sh` and update readme
rynoV Jul 28, 2022
fcae789
Reorganize nginx config files
rynoV Jul 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "plutus-use-cases"]
path = plutus-use-cases
url = https://github.com/mlabs-haskell/plutus-use-cases
[submodule "seabug-contracts"]
path = seabug-contracts
url = [email protected]:mlabs-haskell/seabug-contracts.git
93 changes: 27 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,81 +69,42 @@ Ensure that Nami is set to Testnet, that you have some Test Ada, and that you've

### Optional: Mint your own NFTs

This process will be simplified in the future.
See the minting section in `seabug-contracts/README.md`. The following section describes how to upload an image and get its IPFS CID.

```shell
$ # Setup server admin token, password: seabug
$ PGPASSWORD=seabug psql -U seabug -h localhost -c "INSERT INTO admin_token(token) VALUES ('ADMIN_TOKEN')"

$ # Upload image
$ curl --location --request POST "locahost:8008" \
-F "image=@./cat123.png" \
-F "title=Cat Cat number 123" \
-F "description=Cat eating piece of cheese" \
-H "Authorization: ADMIN_TOKEN"

$ # Get IPFS CID, replace SHA_256_HASH with hash from previous response, note "ipfsHash"
$ curl --location --request GET 'localhost:8008' \
| jq 'to_entries[] | select (.value.sha256hash=="SHA_256_HASH")'

$ # Convert CID, replace "IPFS_HASH" with hash from previous response, note the result
$ ipfs cid format -b=base36 IPFS_HASH

$ # Configure keys for BPI
$ cd plutus-use-cases/mlabs
$ cardano-cli address build \
--payment-verification-key-file payment.vkey \
--out-file payment.addr \
--testnet-magic 1097911063
$ cardano-cli address key-gen \
--verification-key-file payment.vkey \
--signing-key-file payment.skey
$ mkdir -p pab/signing-keys
$ cat payment.addr
$ mv payment.skey pab/signing-keys/signing-key-PKH_HERE.skey

$ # Start BPI, note "minting-policy", it will be used later
$ nix develop -L -c cabal run efficient-nft-pab

$ # In other console
$ # Mint underlying CNFTs, replace "CONVERTED_CID" with the result of `ipfs` command
$ curl --location --request POST 'localhost:3003/api/contract/activate' \
--header 'Content-Type: application/json' \
--data-raw '
{
"caID": {
"tag":"MintCnft",
"contents":[
{
"mc'"'"'name":"Cat number 123",
"mc'"'"'description":"Cat eating piece of cheese",
"mc'"'"'image":"ipfs://CONVERTED_CID",
"mc'"'"'tokenName":"cat-123" # This should be hex encoded (without 0x)
}
]
}
}'

$ # Go back to previous terminal and stop BPI
$ # Replace "CURRENCY_SYMBOL" in /efficient-nft-pab/Main.hs with currency symbol from BPI log
$ # Restart BPI, note "seabug-mint-request"
$ nix develop -L -c cabal run efficient-nft-pab

$ # Mint SeaBug NFT
$ curl --location --request POST 'localhost:3003/api/contract/activate'
--header 'Content-Type: application/json' \
--data-raw 'INSERT_seabug-mint-request_HERE'

$ cd ../cardano-transaction-lib
$ # Replace value of "mintingPolicy1" in seabug_contracts/MintingPolicy.js with policy noted from BPI
#### Upload NFT image

If you have an image:

``` shell
$ cd seabug
$ scripts/upload-image.sh
Arguments: <IMAGE_FILE> <TITLE> <DESCRIPTION>
$ scripts/upload-image.sh 'image.jpeg' 'Title' 'Description'
```

This will add the image to IPFS and the postgres database, and should print out something like:

```
IMAGE: image.jpeg
TITLE: Title
DESC: Description
> IMAGE_HASH: 4cefddfb4f62a3c68d08863cc299a2d6411174c8ff3325d21239ad3b5dcbf21c
> IPFS_HASH: bafkreicm57o7wt3cupdi2ceghtbjtiwwieixjsh7gms5eerzvu5v3s7sdq
> IPFS Base36 CID: k2cwueakfq42m0c5y33czg6ces3tj9b1xlv59krz88y2r8m18e2zxee4
```

The `IPFS Base36 CID` value can be used to continue the minting process.

## Components

### `nft-marketplace`

Frontend for Seabug marketplace, interacts with Cardano blockchain using `cardano-transaction-lib`.

### `seabug-contract`

NFT marketplace contracts in purescript. Onchain part was hardcoded as binary.

### `ogmios-datum-cache`

Caches datums of NFTs that are on available marketplace.
Expand Down
54 changes: 39 additions & 15 deletions arion-compose.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{ pkgs, ... }:
let
nft-marketplace-server =
(pkgs.callPackage (import nft-marketplace-server/release.nix)
{ }).nft-marketplace-server;
ogmios-datum-cache = (import ogmios-datum-cache/default.nix).packages.x86_64-linux.ogmios-datum-cache;
# The address of the marketplace script (`MarketPlace.js` in `seabug-contracts`)
marketplace-escrow-address = "addr_test1wr05mmuhd3nvyjan9u4a7c76gj756am40qg7vuz90vnkjzczfulda";

nft-marketplace-server = (import nft-marketplace-server/default.nix).packages.x86_64-linux."nft-marketplace-server:exe:nft-marketplace-server";
ogmios-datum-cache = (import ogmios-datum-cache/default.nix).packages.x86_64-linux."ogmios-datum-cache";
# FIXME: CTL version also pinned in seabug-contract. We need only one source of truth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be fixed when we'll move from git submodules to flakes, then you can just follow input

cardano-transaction-lib-server = (import
cardano-transaction-lib/default.nix).packages.x86_64-linux."cardano-browser-tx-server:exe:cardano-browser-tx-server";
cardano-transaction-lib/default.nix).packages.x86_64-linux."ctl-server:exe:ctl-server";
in {
# NOTE: still can't remember it...
# ports = [ "host:container" ]
config.services = {

nft-marketplace.service = {
depends_on = {
nft-marketplace-server.condition = "service_healthy";
Expand All @@ -22,7 +25,8 @@ in {
ports = [ "8080:80" ];
volumes = [
"${toString ./.}/nft-marketplace/build:/usr/share/nginx/html"
"${toString ./.}/config/nginx.conf:/etc/nginx/nginx.conf"
"${toString ./.}/config/nginx/nginx.conf:/etc/nginx/nginx.conf"
"${toString ./.}/config/nginx/conf.d:/etc/nginx/conf.d"
];
healthcheck = {
test = [
Expand All @@ -41,46 +45,61 @@ in {
};
useHostStore = true;
};

cardano-transaction-lib-server.service = {
command =
[ "${cardano-transaction-lib-server}/bin/cardano-browser-tx-server" ];
[ "${cardano-transaction-lib-server}/bin/ctl-server"
"--port" "8081"
"--ogmios-host" "ogmios" "--ogmios-port" "1337"
];
ports = [ "8081:8081" ];
useHostStore = true;
volumes = [
"${toString ./.}/data/cardano-node/ipc:/ipc"
];
restart = "always";
};

ogmios.service = {
command = [
"--host"
"0.0.0.0"
"--node-socket"
"/ipc/node.socket"
"--node-config"
"/config/testnet-config.json"
"/config/testnet-node-config.json"
];
depends_on = { cardano-node.condition = "service_healthy"; };
image = "cardanosolutions/ogmios:v5.2.0-testnet";
image = "cardanosolutions/ogmios:v5.5.1-testnet";
ports = [ "1337:1337" ];
volumes = [
"${toString ./.}/data/cardano-node/ipc:/ipc"
"${toString ./.}/config:/config"
];
restart = "always";
};

ogmios-datum-cache.service = {
command = [ "${ogmios-datum-cache}/bin/ogmios-datum-cache" ];
command = [ "${ogmios-datum-cache}/bin/ogmios-datum-cache"
"--db-connection" "host=postgresql-db port=5432 user=seabug dbname=seabug password=seabug"
"--server-port" "9999"
"--server-api" "usr:pwd"
"--ogmios-address" "ogmios" "--ogmios-port" "1337"
"--from-tip" "--use-latest"
"--block-filter" "{\"address\": \"${marketplace-escrow-address}\"}"
];
depends_on = {
ogmios.condition = "service_healthy";
postgresql-db.condition = "service_healthy";
};
ports = [ "9999:9999" ];
useHostStore = true;
volumes = [
"${toString ./.}/config/datum-cache-config.toml:/config/config.toml"
];
working_dir = "/config";
restart = "always";
};

cardano-node.service = {
environment = { NETWORK = "testnet"; };
image = "inputoutput/cardano-node:1.33.0";
image = "inputoutput/cardano-node:1.35.2";
volumes = [
"${toString ./.}/data/cardano-node/ipc:/ipc"
"${toString ./.}/data/cardano-node/cardano-node-data:/data"
Expand All @@ -95,7 +114,9 @@ in {
start_period = "15m";
retries = 3;
};
restart = "always";
};

postgresql-db.service = {
command = [ "-c" "stats_temp_directory=/tmp" ];
environment = {
Expand All @@ -113,7 +134,9 @@ in {
};
volumes =
[ "${toString ./.}/data/postgres-data:/var/lib/postgresql/data" ];
restart = "always";
};

nft-marketplace-server.service = {
image = "alpine";
command = [
Expand Down Expand Up @@ -144,5 +167,6 @@ in {
restart = "always";
volumes = [ "${toString ./.}/config/tmp:/tmp" ];
};

};
}
2 changes: 1 addition & 1 deletion buildFrontend.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nix develop cardano-transaction-lib/ -L --extra-experimental-features "nix-command flakes" -c ./buildFrontendStage2.sh
nix develop seabug-contracts/ -L --extra-experimental-features "nix-command flakes" -c ./buildFrontendStage2.sh
37 changes: 22 additions & 15 deletions buildFrontendStage2.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
set -e
set -x
cd cardano-transaction-lib
npm run bundle-seabug
cd npm-packages/cardano-transaction-lib-seabug

SEABUG=$PWD

cd $SEABUG/seabug-contracts
npm install
cd ../../..
make run-build

cd $SEABUG/nft-marketplace
npm install

# This is a replacement of npm link. npm link is problematic on immutable file systems
rm -rf nft-marketplace/node_modules/cardano-transaction-lib-seabug
mkdir -p $PWD/nft-marketplace/node_modules/
ln -s $PWD/cardano-transaction-lib/npm-packages/cardano-transaction-lib-seabug\
$PWD/nft-marketplace/node_modules/cardano-transaction-lib-seabug
cd nft-marketplace
rm .env
rm -rf $SEABUG/nft-marketplace/node_modules/seabug-contracts
mkdir -p $SEABUG/nft-marketplace/node_modules/
ln -s $SEABUG/seabug-contracts \
$SEABUG/nft-marketplace/node_modules/seabug-contracts

cd $SEABUG/nft-marketplace
rm -f .env
cat <<EOT >> .env
SKIP_PREFLIGHT_CHECK=true
NODE_PATH=./src\
NODE_PATH=./src

REACT_APP_API_BASE_URL=http://api.localho.st:8080
REACT_APP_API_BASE_URL=http://nft-mp-svr.localho.st:8080

REACT_APP_CTL_SERVER_HOST=localho.st
REACT_APP_CTL_SERVER_PORT=8081
REACT_APP_CTL_SERVER_HOST=ctl.localho.st
REACT_APP_CTL_SERVER_PORT=8080
REACT_APP_CTL_SERVER_SECURE_CONN=false

REACT_APP_CTL_OGMIOS_HOST=localho.st
REACT_APP_CTL_OGMIOS_PORT=1337
REACT_APP_CTL_OGMIOS_SECURE_CONN=false

REACT_APP_CTL_DATUM_CACHE_HOST=localho.st
REACT_APP_CTL_DATUM_CACHE_PORT=9999
REACT_APP_CTL_DATUM_CACHE_SECURE_CONN=false
Expand All @@ -32,5 +40,4 @@ REACT_APP_CTL_PROJECT_ID=testnetu7qDM8q2XT1S6gEBSicUIqXB6QN60l7B

REACT_APP_IPFS_BASE_URL=https://cloudflare-ipfs.com/ipfs/
EOT
npm install
npm run build
2 changes: 1 addition & 1 deletion cardano-transaction-lib
Loading