Skip to content

Commit ac97bf3

Browse files
authored
Merge pull request #16 from mlabs-haskell/aleksandr/bump-nftmarketplace
Update all submodules, related fixes and mint automatization
2 parents 9014128 + fcae789 commit ac97bf3

23 files changed

+8129
-1106
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
[submodule "plutus-use-cases"]
1414
path = plutus-use-cases
1515
url = https://github.com/mlabs-haskell/plutus-use-cases
16+
[submodule "seabug-contracts"]
17+
path = seabug-contracts
18+
url = [email protected]:mlabs-haskell/seabug-contracts.git

README.md

Lines changed: 27 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -69,81 +69,42 @@ Ensure that Nami is set to Testnet, that you have some Test Ada, and that you've
6969

7070
### Optional: Mint your own NFTs
7171

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

74-
```shell
75-
$ # Setup server admin token, password: seabug
76-
$ PGPASSWORD=seabug psql -U seabug -h localhost -c "INSERT INTO admin_token(token) VALUES ('ADMIN_TOKEN')"
77-
78-
$ # Upload image
79-
$ curl --location --request POST "locahost:8008" \
80-
-F "image=@./cat123.png" \
81-
-F "title=Cat Cat number 123" \
82-
-F "description=Cat eating piece of cheese" \
83-
-H "Authorization: ADMIN_TOKEN"
84-
85-
$ # Get IPFS CID, replace SHA_256_HASH with hash from previous response, note "ipfsHash"
86-
$ curl --location --request GET 'localhost:8008' \
87-
| jq 'to_entries[] | select (.value.sha256hash=="SHA_256_HASH")'
88-
89-
$ # Convert CID, replace "IPFS_HASH" with hash from previous response, note the result
90-
$ ipfs cid format -b=base36 IPFS_HASH
91-
92-
$ # Configure keys for BPI
93-
$ cd plutus-use-cases/mlabs
94-
$ cardano-cli address build \
95-
--payment-verification-key-file payment.vkey \
96-
--out-file payment.addr \
97-
--testnet-magic 1097911063
98-
$ cardano-cli address key-gen \
99-
--verification-key-file payment.vkey \
100-
--signing-key-file payment.skey
101-
$ mkdir -p pab/signing-keys
102-
$ cat payment.addr
103-
$ mv payment.skey pab/signing-keys/signing-key-PKH_HERE.skey
104-
105-
$ # Start BPI, note "minting-policy", it will be used later
106-
$ nix develop -L -c cabal run efficient-nft-pab
107-
108-
$ # In other console
109-
$ # Mint underlying CNFTs, replace "CONVERTED_CID" with the result of `ipfs` command
110-
$ curl --location --request POST 'localhost:3003/api/contract/activate' \
111-
--header 'Content-Type: application/json' \
112-
--data-raw '
113-
{
114-
"caID": {
115-
"tag":"MintCnft",
116-
"contents":[
117-
{
118-
"mc'"'"'name":"Cat number 123",
119-
"mc'"'"'description":"Cat eating piece of cheese",
120-
"mc'"'"'image":"ipfs://CONVERTED_CID",
121-
"mc'"'"'tokenName":"cat-123" # This should be hex encoded (without 0x)
122-
}
123-
]
124-
}
125-
}'
126-
127-
$ # Go back to previous terminal and stop BPI
128-
$ # Replace "CURRENCY_SYMBOL" in /efficient-nft-pab/Main.hs with currency symbol from BPI log
129-
$ # Restart BPI, note "seabug-mint-request"
130-
$ nix develop -L -c cabal run efficient-nft-pab
131-
132-
$ # Mint SeaBug NFT
133-
$ curl --location --request POST 'localhost:3003/api/contract/activate'
134-
--header 'Content-Type: application/json' \
135-
--data-raw 'INSERT_seabug-mint-request_HERE'
136-
137-
$ cd ../cardano-transaction-lib
138-
$ # Replace value of "mintingPolicy1" in seabug_contracts/MintingPolicy.js with policy noted from BPI
74+
#### Upload NFT image
75+
76+
If you have an image:
77+
78+
``` shell
79+
$ cd seabug
80+
$ scripts/upload-image.sh
81+
Arguments: <IMAGE_FILE> <TITLE> <DESCRIPTION>
82+
$ scripts/upload-image.sh 'image.jpeg' 'Title' 'Description'
83+
```
84+
85+
This will add the image to IPFS and the postgres database, and should print out something like:
86+
87+
```
88+
IMAGE: image.jpeg
89+
TITLE: Title
90+
DESC: Description
91+
> IMAGE_HASH: 4cefddfb4f62a3c68d08863cc299a2d6411174c8ff3325d21239ad3b5dcbf21c
92+
> IPFS_HASH: bafkreicm57o7wt3cupdi2ceghtbjtiwwieixjsh7gms5eerzvu5v3s7sdq
93+
> IPFS Base36 CID: k2cwueakfq42m0c5y33czg6ces3tj9b1xlv59krz88y2r8m18e2zxee4
13994
```
14095

96+
The `IPFS Base36 CID` value can be used to continue the minting process.
97+
14198
## Components
14299

143100
### `nft-marketplace`
144101

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

104+
### `seabug-contract`
105+
106+
NFT marketplace contracts in purescript. Onchain part was hardcoded as binary.
107+
147108
### `ogmios-datum-cache`
148109

149110
Caches datums of NFTs that are on available marketplace.

arion-compose.nix

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
{ pkgs, ... }:
22
let
3-
nft-marketplace-server =
4-
(pkgs.callPackage (import nft-marketplace-server/release.nix)
5-
{ }).nft-marketplace-server;
6-
ogmios-datum-cache = (import ogmios-datum-cache/default.nix).packages.x86_64-linux.ogmios-datum-cache;
3+
# The address of the marketplace script (`MarketPlace.js` in `seabug-contracts`)
4+
marketplace-escrow-address = "addr_test1wr05mmuhd3nvyjan9u4a7c76gj756am40qg7vuz90vnkjzczfulda";
5+
6+
nft-marketplace-server = (import nft-marketplace-server/default.nix).packages.x86_64-linux."nft-marketplace-server:exe:nft-marketplace-server";
7+
ogmios-datum-cache = (import ogmios-datum-cache/default.nix).packages.x86_64-linux."ogmios-datum-cache";
8+
# FIXME: CTL version also pinned in seabug-contract. We need only one source of truth
79
cardano-transaction-lib-server = (import
8-
cardano-transaction-lib/default.nix).packages.x86_64-linux."cardano-browser-tx-server:exe:cardano-browser-tx-server";
10+
cardano-transaction-lib/default.nix).packages.x86_64-linux."ctl-server:exe:ctl-server";
911
in {
1012
# NOTE: still can't remember it...
1113
# ports = [ "host:container" ]
1214
config.services = {
15+
1316
nft-marketplace.service = {
1417
depends_on = {
1518
nft-marketplace-server.condition = "service_healthy";
@@ -22,7 +25,8 @@ in {
2225
ports = [ "8080:80" ];
2326
volumes = [
2427
"${toString ./.}/nft-marketplace/build:/usr/share/nginx/html"
25-
"${toString ./.}/config/nginx.conf:/etc/nginx/nginx.conf"
28+
"${toString ./.}/config/nginx/nginx.conf:/etc/nginx/nginx.conf"
29+
"${toString ./.}/config/nginx/conf.d:/etc/nginx/conf.d"
2630
];
2731
healthcheck = {
2832
test = [
@@ -41,46 +45,61 @@ in {
4145
};
4246
useHostStore = true;
4347
};
48+
4449
cardano-transaction-lib-server.service = {
4550
command =
46-
[ "${cardano-transaction-lib-server}/bin/cardano-browser-tx-server" ];
51+
[ "${cardano-transaction-lib-server}/bin/ctl-server"
52+
"--port" "8081"
53+
"--ogmios-host" "ogmios" "--ogmios-port" "1337"
54+
];
4755
ports = [ "8081:8081" ];
4856
useHostStore = true;
57+
volumes = [
58+
"${toString ./.}/data/cardano-node/ipc:/ipc"
59+
];
60+
restart = "always";
4961
};
62+
5063
ogmios.service = {
5164
command = [
5265
"--host"
5366
"0.0.0.0"
5467
"--node-socket"
5568
"/ipc/node.socket"
5669
"--node-config"
57-
"/config/testnet-config.json"
70+
"/config/testnet-node-config.json"
5871
];
5972
depends_on = { cardano-node.condition = "service_healthy"; };
60-
image = "cardanosolutions/ogmios:v5.2.0-testnet";
73+
image = "cardanosolutions/ogmios:v5.5.1-testnet";
6174
ports = [ "1337:1337" ];
6275
volumes = [
6376
"${toString ./.}/data/cardano-node/ipc:/ipc"
6477
"${toString ./.}/config:/config"
6578
];
79+
restart = "always";
6680
};
81+
6782
ogmios-datum-cache.service = {
68-
command = [ "${ogmios-datum-cache}/bin/ogmios-datum-cache" ];
83+
command = [ "${ogmios-datum-cache}/bin/ogmios-datum-cache"
84+
"--db-connection" "host=postgresql-db port=5432 user=seabug dbname=seabug password=seabug"
85+
"--server-port" "9999"
86+
"--server-api" "usr:pwd"
87+
"--ogmios-address" "ogmios" "--ogmios-port" "1337"
88+
"--from-tip" "--use-latest"
89+
"--block-filter" "{\"address\": \"${marketplace-escrow-address}\"}"
90+
];
6991
depends_on = {
7092
ogmios.condition = "service_healthy";
7193
postgresql-db.condition = "service_healthy";
7294
};
7395
ports = [ "9999:9999" ];
7496
useHostStore = true;
75-
volumes = [
76-
"${toString ./.}/config/datum-cache-config.toml:/config/config.toml"
77-
];
78-
working_dir = "/config";
7997
restart = "always";
8098
};
99+
81100
cardano-node.service = {
82101
environment = { NETWORK = "testnet"; };
83-
image = "inputoutput/cardano-node:1.33.0";
102+
image = "inputoutput/cardano-node:1.35.2";
84103
volumes = [
85104
"${toString ./.}/data/cardano-node/ipc:/ipc"
86105
"${toString ./.}/data/cardano-node/cardano-node-data:/data"
@@ -95,7 +114,9 @@ in {
95114
start_period = "15m";
96115
retries = 3;
97116
};
117+
restart = "always";
98118
};
119+
99120
postgresql-db.service = {
100121
command = [ "-c" "stats_temp_directory=/tmp" ];
101122
environment = {
@@ -113,7 +134,9 @@ in {
113134
};
114135
volumes =
115136
[ "${toString ./.}/data/postgres-data:/var/lib/postgresql/data" ];
137+
restart = "always";
116138
};
139+
117140
nft-marketplace-server.service = {
118141
image = "alpine";
119142
command = [
@@ -144,5 +167,6 @@ in {
144167
restart = "always";
145168
volumes = [ "${toString ./.}/config/tmp:/tmp" ];
146169
};
170+
147171
};
148172
}

buildFrontend.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nix develop cardano-transaction-lib/ -L --extra-experimental-features "nix-command flakes" -c ./buildFrontendStage2.sh
1+
nix develop seabug-contracts/ -L --extra-experimental-features "nix-command flakes" -c ./buildFrontendStage2.sh

buildFrontendStage2.sh

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
set -e
22
set -x
3-
cd cardano-transaction-lib
4-
npm run bundle-seabug
5-
cd npm-packages/cardano-transaction-lib-seabug
3+
4+
SEABUG=$PWD
5+
6+
cd $SEABUG/seabug-contracts
67
npm install
7-
cd ../../..
8+
make run-build
9+
10+
cd $SEABUG/nft-marketplace
11+
npm install
12+
813
# This is a replacement of npm link. npm link is problematic on immutable file systems
9-
rm -rf nft-marketplace/node_modules/cardano-transaction-lib-seabug
10-
mkdir -p $PWD/nft-marketplace/node_modules/
11-
ln -s $PWD/cardano-transaction-lib/npm-packages/cardano-transaction-lib-seabug\
12-
$PWD/nft-marketplace/node_modules/cardano-transaction-lib-seabug
13-
cd nft-marketplace
14-
rm .env
14+
rm -rf $SEABUG/nft-marketplace/node_modules/seabug-contracts
15+
mkdir -p $SEABUG/nft-marketplace/node_modules/
16+
ln -s $SEABUG/seabug-contracts \
17+
$SEABUG/nft-marketplace/node_modules/seabug-contracts
18+
19+
cd $SEABUG/nft-marketplace
20+
rm -f .env
1521
cat <<EOT >> .env
1622
SKIP_PREFLIGHT_CHECK=true
17-
NODE_PATH=./src\
23+
NODE_PATH=./src
1824
19-
REACT_APP_API_BASE_URL=http://api.localho.st:8080
25+
REACT_APP_API_BASE_URL=http://nft-mp-svr.localho.st:8080
2026
21-
REACT_APP_CTL_SERVER_HOST=localho.st
22-
REACT_APP_CTL_SERVER_PORT=8081
27+
REACT_APP_CTL_SERVER_HOST=ctl.localho.st
28+
REACT_APP_CTL_SERVER_PORT=8080
2329
REACT_APP_CTL_SERVER_SECURE_CONN=false
30+
2431
REACT_APP_CTL_OGMIOS_HOST=localho.st
2532
REACT_APP_CTL_OGMIOS_PORT=1337
2633
REACT_APP_CTL_OGMIOS_SECURE_CONN=false
34+
2735
REACT_APP_CTL_DATUM_CACHE_HOST=localho.st
2836
REACT_APP_CTL_DATUM_CACHE_PORT=9999
2937
REACT_APP_CTL_DATUM_CACHE_SECURE_CONN=false
@@ -32,5 +40,4 @@ REACT_APP_CTL_PROJECT_ID=testnetu7qDM8q2XT1S6gEBSicUIqXB6QN60l7B
3240
3341
REACT_APP_IPFS_BASE_URL=https://cloudflare-ipfs.com/ipfs/
3442
EOT
35-
npm install
3643
npm run build

cardano-transaction-lib

0 commit comments

Comments
 (0)