Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 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
146 changes: 81 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,73 +69,85 @@ 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.
UPDATE: see the minting section in `seabug-contracts/README.md` instead. The following minting process is currently broken, see [\#22](https://github.com/mlabs-haskell/seabug/issues/22).
Copy link
Contributor

Choose a reason for hiding this comment

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

Keeping broken process in readme can be confusing even if it's marked as broken

Copy link
Contributor

Choose a reason for hiding this comment

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

Unsure if its the right move to drop the full minting util, I feel like probably not, but we can certainly do so from the readme, and add back later once fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

The new minting process partially relies on mint-nft.sh to upload an image to IPFS+our database and get its base36 CID, and some of the setup from this section of the readme is necessary for that to work. It's kind of hacky right now, but I'm not sure if it's worth trying to extract out the part of mint-nft.sh that we need.

Maybe we just remove mint-nft.sh for now, but keeping the parts that are needed? The file is in git anyways

Copy link
Contributor

Choose a reason for hiding this comment

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

See 43dad7d for what I meant. I can revert that commit if we want to keep the old version, but I feel like it'll just cause confusion


#### Start plutus-chain-index

Set environment variables:

``` shell
$ pwd
.../seabug
$ export CARDANO_NODE_SOCKET_PATH=$PWD/data/cardano-node/ipc/node.socket
$ mkdir -p chain-index
$ export CHAIN_INDEX_PATH=$PWD/chain-index/chain-index.sqlite
```

Fix permission problem for `node.socket` (if you receive error like: `plutus-chain-index: Network.Socket.connect: <socket: 35>: permission denied (Permission denied)`):

``` shell
$ sudo chmod 0666 $CARDANO_NODE_SOCKET_PATH
```

Building and run plutus-chain-index from the source:

```
$ cd ..
$ git clone [email protected]:input-output-hk/plutus-apps.git
$ cd plutus-apps
$ nix build -f default.nix plutus-chain-index
$ result/bin/plutus-chain-index start-index --network-id 1097911063 --db-path $CHAIN_INDEX_PATH/chain-index.sqlite --socket-path $CARDANO_NODE_SOCKET_PATH
```

The index should be synced for minting.

#### Prepare wallet

``` shell
$ cd seabug
$ nix develop
$ scripts/prepare-wallet.sh
new wallet generated:
address: addr_test1vp3tywa08qjjj7mplzmwjs9kmes0ce3ud5da3x0wppu5e9qgxqhps
PHK: 62b23baf3825297b61f8b6e940b6de60fc663c6d1bd899ee08794c94
file: payment.addr
file: payment.vkey
file: pab/signing-keys/signing-key-62b23baf3825297b61f8b6e940b6de60fc663c6d1bd899ee08794c94.skey
```

Add some Ada to your wallet:
- by Nami wallet
- or by [Faucet](https://testnets.cardano.org/en/testnets/cardano/tools/faucet/)

Check the result:

```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
$ cd seabug
$ cardano-cli query utxo --testnet-magic 1097911063 --address $(cat payment.addr)
TxHash TxIx Amount
--------------------------------------------------------------------------------------
ed11c8765d764852d049cd1a2239524ade0c6057a3a51146dc8c9d7bcbe008e0 0 100000000 lovelace + TxOutDatumNone
```

#### Mint your own NFT

If you have an image:

``` shell
$ cd seabug
$ scripts/mint-nft.sh
Arguments: <IMAGE_FILE> <TITLE> <DESCRIPTION> <TOKEN_NAME> <MINT_POLICY> [<IPFS_CID>]
<MINT_POLICY> - arbitrary string to identify mint policy
$ scripts/mint-nft.sh 'image.jpeg' 'Title' 'Description' 'Token name' 'mintPolicy'
```

The script take some time to work, especially if you haven't used efficient_nft_pab before (`cd plutus-use-cases/mlabs && nix develop -c cabal run efficient-nft-pab --disable-optimisation`).

If you already uploaded the image to nft.storage and have IPFC_CID (you can get it from nft.storage web interface).

``` shell
$ cd seabug
$ scripts/mint-nft.sh 'image.jpeg' 'Title' 'Description' 'Token name' 'mintPolicy' k2cwueaf1ew3nr2gq2rw83y13m2f5jpg8uyymn66kr8ogeglrwcou5u8
```

## Components
Expand All @@ -144,6 +156,10 @@ $ # Replace value of "mintingPolicy1" in seabug_contracts/MintingPolicy.js with

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
48 changes: 34 additions & 14 deletions arion-compose.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{ 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;
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 Down Expand Up @@ -41,46 +41,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/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\": \"addr_test1wr05mmuhd3nvyjan9u4a7c76gj756am40qg7vuz90vnkjzczfulda\"}"
Copy link
Contributor

Choose a reason for hiding this comment

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

This address seems like it shouldn't be hardcoded, is it the marketplace address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is. The issue on this: #18

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be probably some const defined earlier in this file, it's constant after launch, it's 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 +110,9 @@ in {
start_period = "15m";
retries = 3;
};
restart = "always";
};

postgresql-db.service = {
command = [ "-c" "stats_temp_directory=/tmp" ];
environment = {
Expand All @@ -113,7 +130,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 +163,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