Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
avkr003 committed Jan 25, 2024
0 parents commit 8189362
Show file tree
Hide file tree
Showing 3,057 changed files with 931,986 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.github
README.md
wrangler.toml
.gitignore
Binary file added .github/.DS_Store
Binary file not shown.
114 changes: 114 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Mantleplace - CI

on:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup docker builder
uses: docker/setup-buildx-action@v1
with: { install: true }

- name: set GitHub short sha
run: |
echo $GITHUB_SHA | head -c 8
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | head -c 8)" >> $GITHUB_ENV
- name: Test sbt dist
uses: docker/build-push-action@v2
if: ${{ !(github.ref_type == 'tag' || (github.ref_type == 'branch' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging'))) }}
with:
target: build
push: false
cache-from: type=gha
build-args: |
APP_VERSION=${{ env.GITHUB_SHA_SHORT }}
- name: Test sbt dist (cached)
uses: docker/build-push-action@v2
if: ${{ github.ref_type == 'tag' || (github.ref_type == 'branch' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging')) }}
with:
target: build
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
APP_VERSION=${{ env.GITHUB_SHA_SHORT }}
- name: Prepare production release tags
id: meta
uses: docker/metadata-action@v3
if: ${{ github.ref_type == 'tag' }}
with:
images: |
assetmantle/mantleplace
tags: |
type=raw,value=latest-{{sha}}-{{date 'X'}}
type=raw,value=latest
- name: Prepare staging release ragas
id: meta-branch
uses: docker/metadata-action@v3
if: ${{ github.ref_type == 'branch' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
with:
images: |
assetmantle/mantleplace
tags: |
type=raw,value=edge-{{sha}}-{{date 'X'}}
type=raw,value=edge
- name: Prepare staging2 release ragas
id: meta-staging
uses: docker/metadata-action@v3
if: ${{ github.ref_type == 'branch' && (github.ref == 'refs/heads/staging') }}
with:
images: |
assetmantle/mantleplace
tags: |
type=raw,value=staging-{{sha}}-{{date 'X'}}
type=raw,value=staging
- name: Login to docker registry
uses: docker/login-action@v1
if: ${{ github.ref_type == 'tag' || (github.ref_type == 'branch' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging')) }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build production container image
uses: docker/build-push-action@v2
if: ${{ github.ref_type == 'tag' }}
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
APP_VERSION=${{ env.GITHUB_SHA_SHORT }}
- name: Build staging container image
uses: docker/build-push-action@v2
if: ${{ github.ref_type == 'branch' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
with:
push: true
tags: ${{ steps.meta-branch.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
APP_VERSION=${{ env.GITHUB_SHA_SHORT }}
- name: Build staging2 container image
uses: docker/build-push-action@v2
if: ${{ github.ref_type == 'branch' && (github.ref == 'refs/heads/staging') }}
with:
push: true
tags: ${{ steps.meta-staging.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
APP_VERSION=${{ env.GITHUB_SHA_SHORT }}
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
target
/.bsp
/.idea
/logs
/RUNNING_PID
# Ignore Play! working directory #
bin/
/db
.eclipse
/lib/
/logs/
/modules
/project/project
/project/target
/target
tmp/
test-result
server.pid
*.eml
/dist/
.cache
65 changes: 65 additions & 0 deletions .run/Ticketing.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Ticketing" type="Play2FrameworkRunConfigurations" factoryName="Play 2 App" show_console_on_std_err="false" show_console_on_std_out="false">
<module name="Ticketing" />
<option name="allowRunningInParallel" value="false" />
<option name="enableSbtGlobalPlugins" value="false" />
<option name="play2EnvVariables">
<map>
<entry key="AMAZON_S3_ACCESS_KEY_ID" value="AKIAYNFEJ2MUSSZZ7NIW" />
<entry key="AMAZON_S3_BUCKET_NAME" value="assetmantle-test-collection" />
<entry key="AMAZON_S3_BUCKET_URL" value="https://assetmantle-test-collection.s3.ap-south-1.amazonaws.com/" />
<entry key="AMAZON_S3_REGION" value="ap-south-1" />
<entry key="AMAZON_S3_SECRET_KEY" value="DXW8VyWpkvgV9Q8kVpzacip3KZVxGYCnlL/HoT7A" />
<entry key="APPLICATION_SECRET" value="d7oJaPFAnguWe8OU8aeST964GeR_XJ5TS[ho@_];VBq8sQ0kNBM@v/psglncUr&amp;gt;x" />
<entry key="APP_VERSION" value="v0.1.11" />
<entry key="BLOCKCHAIN_CHAIN_ID" value="mantle-1" />
<entry key="BLOCKCHAIN_NAME" value="AssetMantle Testnet" />
<entry key="BLOCKCHAIN_REST" value="http://localhost:1317" />
<entry key="BLOCKCHAIN_RPC" value="http://localhost:26657" />
<entry key="BLOCKCHAIN_STAKING_DENOM" value="umntl" />
<entry key="BLOCKCHAIN_UPGRADE_HEIGHT" value="1" />
<entry key="COLLECTION_PATH" value="$USER_HOME$/collections" />
<entry key="ENABLE_NFT_MINT_AIRDROP" value="false" />
<entry key="EXPLORER_POSTGRES_DB" value="assetMantle" />
<entry key="EXPLORER_POSTGRES_PASSWORD" value="assetMantle" />
<entry key="EXPLORER_POSTGRES_URL" value="localhost:5432" />
<entry key="EXPLORER_POSTGRES_USER" value="assetMantle" />
<entry key="IPFS_DOWNLOAD_ACCESS_TOKEN" value="fvrEF-HHdNz0-SPqNqnxcUzSBGvmeXJ1dxrNFiv1nksI-e0DOoEI7Uz3pfT6VxDp" />
<entry key="IPFS_DOWNLOAD_END_POINT" value="https://lavender-important-scorpion-842.mypinata.cloud/ipfs" />
<entry key="IPFS_JWT" value="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsiaWQiOiIwMjYwZmRmYi1lZmRjLTRmZTktOGYwYi1jZjg4OTExOGFmMjkiLCJlbWFpbCI6InB1bmVldEBwZXJzaXN0ZW5jZS5vbmUiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwicGluX3BvbGljeSI6eyJyZWdpb25zIjpbeyJpZCI6IkZSQTEiLCJkZXNpcmVkUmVwbGljYXRpb25Db3VudCI6MX1dLCJ2ZXJzaW9uIjoxfSwibWZhX2VuYWJsZWQiOmZhbHNlfSwiYXV0aGVudGljYXRpb25UeXBlIjoic2NvcGVkS2V5Iiwic2NvcGVkS2V5S2V5IjoiYTAyMWI1MWMzZWVlOGQ2NWU0MjciLCJzY29wZWRLZXlTZWNyZXQiOiJiNzQyMmQ5ZDNhNGQyNzViYmI0M2VhMDU1OTlmNzA2ODgzZTUxNjMyNzcxMjRiYjZlOWM5Yjg2YjBkZDBhNGUyIiwiaWF0IjoxNjM0NjQ5MTg4fQ.i514LU4xYYu95OvuZJ6vhWKgUqmXxnkhMMmDw-GmpCg" />
<entry key="IPFS_UPLOAD_END_POINT" value="https://api.pinata.cloud/pinning/pinFileToIPFS" />
<entry key="KEY_STORE_PASSWORD" value="123123123" />
<entry key="KEY_STORE_PATH" value="$USER_HOME$/AssetMantleKeyStore" />
<entry key="POSTGRES_DB" value="ticketing" />
<entry key="POSTGRES_PASSWORD" value="ticketing" />
<entry key="POSTGRES_URL" value="localhost:5432" />
<entry key="POSTGRES_USER" value="ticketing" />
<entry key="ROOT_FILE_PATH" value="$USER_HOME$/" />
<entry key="SECRET" value="Jj%Sr!xrC9G!xKS5^yF!UPYa!DkWo@N*R^xjF6vC@nAL@zaD24WqHfbTZ^QbYFsj^^j9LExb3@Rt9Yfj!4amcHY%5$bC#SU$DorA6Hv6h2i%bh%M$XFfDVVpW!fJd" />
<entry key="SITE_URL" value="http://localhost:9000" />
</map>
</option>
<option name="play2IsNonDefaultInstallDirUsed" value="false" />
<option name="play2JpdaPort" value="9999" />
<option name="play2JvmOptions">
<array>
<option value="-Xms512M" />
<option value="-Xmx1024M" />
<option value="-Xss1M" />
<option value="-XX:+CMSClassUnloadingEnabled" />
<option value="-XX:MaxPermSize=256M" />
</array>
</option>
<option name="play2NeedOpenInBrowser" value="true" />
<option name="play2NonDefaultInstallDir" value="" />
<option name="play2OpenUrl" value="http://localhost:9000" />
<option name="play2isAutoReloadEnabled" value="true" />
<option name="projectPathOnTarget" />
<option name="selectedOptions">
<list />
</option>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
8 changes: 8 additions & 0 deletions ADR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Account:

### Blockchain Transactions:
* Made two tables `AdminTransaction` and `UserTransaction` instead of individual table for each transaction (15 tx) -
* [PRO] Fetching Tx history for an account sorted on time is far less complex when fetching from 15 tables (in other case)
* [PRO] Code maintenance is hugely improved as only 2 schedulers needs to be run instead of 15.
* [CON] Tx type needs to be stored.
* `AdminTransaction` and `UserTransaction` 2 different tables as they might get slightly different logic in scheduler.
64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# syntax=docker/dockerfile:latest
ARG BUILD_IMAGE=adoptopenjdk:11-jdk-hotspot
ARG JRE_IMAGE=adoptopenjdk:11-jre-hotspot

FROM $BUILD_IMAGE as build
ARG SBT_VERSION=1.7.2
SHELL [ "/bin/bash", "-cxe" ]
WORKDIR /tmp
RUN curl -sLo - https://github.com/sbt/sbt/releases/download/v${SBT_VERSION}/sbt-${SBT_VERSION}.tgz | tar -xvzf -; \
mv sbt/bin/* /usr/local/bin/; \
rm -rf /tmp/*
WORKDIR /app
ENV JAVA_OPTS="-Xms4G -Xmx8G -Xss6M -XX:ReservedCodeCacheSize=256M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC"
ENV JVM_OPTS="-Xms4G -Xmx8G -Xss6M -XX:ReservedCodeCacheSize=256M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC"
ENV SBT_OPTS="-Xms4G -Xmx8G -Xss6M -XX:ReservedCodeCacheSize=256M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC"
ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION
COPY . .
RUN --mount=type=cache,target=/root/.sbt \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.ivy2 \
sbt dist; \
echo $APP_VERSION

FROM $BUILD_IMAGE as extract
SHELL [ "/bin/bash", "-cxe" ]
WORKDIR /app
RUN --mount=type=cache,target=/var/lib/apt/cache \
--mount=type=cache,target=/var/lib/cache \
apt update; \
apt install unzip -y
COPY --from=build /app/target/universal/ /app
RUN <<EOF
cp *.zip mantleplace.zip
ls -alt
unzip -q mantleplace.zip
ls -alt
rm *.zip
ls -alt
mv mantleplace* mantleplace
ls -alt
# awk 'NR==1{print; print "set -x"} NR!=1' mantleplace/bin/mantleplace > mantleplace/bin/mantleplace.tmp
# mv mantleplace/bin/mantleplace.tmp mantleplace/bin/mantleplace
# chmod +x mantleplace/bin/mantleplace
# head -n 10 mantleplace/bin/mantleplace
EOF

FROM $JRE_IMAGE
ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION
LABEL org.opencontainers.image.title=mantleplace
LABEL org.opencontainers.image.base.name=$JRE_IMAGE
LABEL org.opencontainers.image.description=mantleplace
LABEL org.opencontainers.image.source=https://github.com/assetmantle/mantleplace
LABEL org.opencontainers.image.documentation=https://github.com/assetmantle/mantleplace
WORKDIR /
RUN --mount=type=cache,target=/var/lib/apt/cache \
--mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/lib/cache \
--mount=type=cache,target=/var/cache/apt/archives \
apt update; \
apt install -y openssl libexpat1 libsasl2-2 libssl1.1 libsasl2-modules-db
COPY --from=extract /app/mantleplace /mantleplace
ENTRYPOINT [ "/mantleplace/bin/mantleplace" ]
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Mantleplace

## Running MantlePlace directly from Intellij Idea

- Install Intellij Ultimate version from their [website](https://www.jetbrains.com/idea/)

### Prerequisites:

1. Install `sdkman`:
```shell
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
```
2. Install `Java 11.0.x`:
1. `sdk install java 11.0.11.hs-adpt`
3. Install `sbt 1.6.2` or the version mentioned in `project/build.properties`:
1. `sdk install sbt 1.6.2`
4. Install `PostgreSQL 14`:
1. [MacOS](https://postgresapp.com) (Make default username and password `postgres` and `postgres` respectively)
2. Ubuntu:
```shell
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RELEASE=$(lsb_release -cs)
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt update
sudo apt -y install postgresql-14
sudo su - postgres or psql -U postgres
psql -c "alter user postgres with password 'postgres'"
exit
```

### Starting Client in Intellij:

1. Click on `Database` on right then on `+` -> `DataSource` -> `PostgreSQL`
2. Fill the following:
1. `User`: `postgres`
2. `Password`: `postgres`
3. `URL`: `jdbc:postgresql://localhost:5432/postgres`
4. `Database`: `postgres`
5. `Save`: `Forever`
6. Do `Test Connection` this should succeed. Then `Apply` -> `OK`
3. Select `0.sql` contents and execute in `console`
4. Update `MantlePlace.run.xml` with correct values and the run by selecting `MantlePlace configuration` and clicking
Run icon next to it. Debug is next to it.
5. Click on `Database` on right then on `stack + wrench`, go to `Schema` and select `mantlePlace` and all its tables to
view.

### Starting Client on Terminal:

1. `sudo su - postgres`
2. `psql`
3. Copy contents of `0.sql` and paste there
4. `\q`
5. `exit`
6. Set all the environment variables in `application.conf` (They are of form `${NAME}`)
7. Create binary for client:
1. Go to project directory in terminal.
2. `sbt clean`
3. `sbt dist`
4. You get a `assetMantle-1.0.zip` file which contains binary file in `bin` folder.
8. Modify `applicaltion.conf` as per the requirements.
9. Run `./persistenceclient`

## Local development setup

- Install docker on your machine

- Macos: get it
from [here https://docs.docker.com/desktop/mac/install/](https://docs.docker.com/desktop/mac/install/)

- Linux

```shell
curl -sL get.docker.com | sudo bash
docker buildx install
docker version
docker buildx version
```


- Install `docker-compose` on your machine

- Macos: get it from [here https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)

- Linux

```shell
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep tag_name | cut -d : -f2 | cut -d , -f1 | xargs)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose version
```

## Note

Before running the mantleplace on your local, make sure that your postgresql database is enabled.

## Run mantleplace

```shell
docker-compose up
```
Binary file added app/.DS_Store
Binary file not shown.
Loading

0 comments on commit 8189362

Please sign in to comment.