Skip to content

Commit 2979b43

Browse files
committed
Merge branch 'aleksandr/bump-nftmarketplace' into aciceri/use-flake-reprise
2 parents fe8584e + fcae789 commit 2979b43

17 files changed

+11406
-2163
lines changed

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: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
let
44
inherit (config) share_dir nft-storage-key;
55
inherit (pkgs.lib) mkOption;
6+
# The address of the marketplace script (`MarketPlace.js` in `seabug-contracts`)
7+
marketplace-escrow-address = "addr_test1wr05mmuhd3nvyjan9u4a7c76gj756am40qg7vuz90vnkjzczfulda";
8+
9+
# FIXME: CTL version also pinned in seabug-contract. We need only one source of truth
610
in
711

812
{
@@ -19,6 +23,7 @@ in
1923
# NOTE: still can't remember it...
2024
# ports = [ "host:container" ]
2125
config.services = {
26+
2227
nft-marketplace.service = {
2328
depends_on = {
2429
nft-marketplace-server.condition = "service_healthy";
@@ -32,7 +37,8 @@ in
3237
volumes = [
3338
# "${toString ./.}/nft-marketplace/build:/usr/share/nginx/html"
3439
"${pkgs.nft-marketplace-frontend-artifacts}:/usr/share/nginx/html"
35-
"${toString ./.}/config/nginx.conf:/etc/nginx/nginx.conf"
40+
"${toString ./.}/config/nginx/nginx.conf:/etc/nginx/nginx.conf"
41+
"${toString ./.}/config/nginx/conf.d:/etc/nginx/conf.d"
3642
];
3743
healthcheck = {
3844
test = [
@@ -51,46 +57,77 @@ in
5157
};
5258
useHostStore = true;
5359
};
60+
5461
cardano-transaction-lib-server.service = {
5562
command =
56-
[ "${pkgs.cardano-transaction-lib-server}/bin/cardano-browser-tx-server" ];
63+
# [ "${pkgs.cardano-transaction-lib-server}/bin/cardano-browser-tx-server" ];
64+
[
65+
"${pkgs.cardano-transaction-lib-server}/bin/ctl-server"
66+
"--port"
67+
"8081"
68+
"--ogmios-host"
69+
"ogmios"
70+
"--ogmios-port"
71+
"1337"
72+
];
5773
ports = [ "8081:8081" ];
5874
useHostStore = true;
75+
volumes = [
76+
"${share_dir}/data/cardano-node/ipc:/ipc"
77+
];
78+
restart = "always";
5979
};
80+
6081
ogmios.service = {
6182
command = [
6283
"--host"
6384
"0.0.0.0"
6485
"--node-socket"
6586
"/ipc/node.socket"
6687
"--node-config"
67-
"/config/testnet-config.json"
88+
"/config/testnet-node-config.json"
6889
];
6990
depends_on = { cardano-node.condition = "service_healthy"; };
70-
image = "cardanosolutions/ogmios:v5.2.0-testnet";
91+
image = "cardanosolutions/ogmios:v5.5.1-testnet";
7192
ports = [ "1337:1337" ];
7293
volumes = [
7394
"${share_dir}/data/cardano-node/ipc:/ipc"
7495
"${toString ./.}/config:/config"
7596
];
97+
restart = "always";
7698
};
99+
77100
ogmios-datum-cache.service = {
78-
command = [ "${pkgs.ogmios-datum-cache}/bin/ogmios-datum-cache" ];
101+
command = [
102+
"${pkgs.ogmios-datum-cache}/bin/ogmios-datum-cache"
103+
"--db-connection"
104+
"host=postgresql-db port=5432 user=seabug dbname=seabug password=seabug"
105+
"--server-port"
106+
"9999"
107+
"--server-api"
108+
"usr:pwd"
109+
"--ogmios-address"
110+
"ogmios"
111+
"--ogmios-port"
112+
"1337"
113+
"--from-tip"
114+
"--use-latest"
115+
"--block-filter"
116+
# TODO: toJSON
117+
"{\"address\": \"${marketplace-escrow-address}\"}"
118+
];
79119
depends_on = {
80120
ogmios.condition = "service_healthy";
81121
postgresql-db.condition = "service_healthy";
82122
};
83123
ports = [ "9999:9999" ];
84124
useHostStore = true;
85-
volumes = [
86-
"${toString ./.}/config/datum-cache-config.toml:/config/config.toml"
87-
];
88-
working_dir = "/config";
89125
restart = "always";
90126
};
127+
91128
cardano-node.service = {
92129
environment = { NETWORK = "testnet"; };
93-
image = "inputoutput/cardano-node:1.33.0";
130+
image = "inputoutput/cardano-node:1.35.2";
94131
volumes = [
95132
"${share_dir}/data/cardano-node/ipc:/ipc"
96133
"${share_dir}/data/cardano-node/cardano-node-data:/data"
@@ -105,7 +142,9 @@ in
105142
start_period = "120m";
106143
retries = 3;
107144
};
145+
restart = "always";
108146
};
147+
109148
postgresql-db.service = {
110149
command = [ "-c" "stats_temp_directory=/tmp" ];
111150
environment = {
@@ -124,7 +163,9 @@ in
124163
volumes = [
125164
"${share_dir}/data/postgres-data:/var/lib/postgresql/data"
126165
];
166+
restart = "always";
127167
};
168+
128169
nft-marketplace-server.service = {
129170
image = "alpine";
130171
command = [
@@ -157,5 +198,6 @@ in
157198
"${share_dir}/config/tmp:/tmp"
158199
];
159200
};
201+
160202
};
161203
}

buildFrontend.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<<<<<<< HEAD
12
nix develop ".#stage2" -L --extra-experimental-features "nix-command flakes" -c ./buildFrontendStage2.sh
3+
=======
4+
nix develop seabug-contracts/ -L --extra-experimental-features "nix-command flakes" -c ./buildFrontendStage2.sh
5+
>>>>>>> aleksandr/bump-nftmarketplace

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

0 commit comments

Comments
 (0)