Skip to content

Commit

Permalink
v1.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
cindyssun5 committed May 6, 2021
0 parents commit a3a4968
Show file tree
Hide file tree
Showing 213 changed files with 24,391 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NEXT_PUBLIC_CHAIN_ENDPOINTS='https://testnet.protonchain.com'
NEXT_PUBLIC_BLOCK_EXPLORER='https://proton-test.bloks.io/block/'
NEXT_PUBLIC_NFT_ENDPOINT='https://test.proton.api.atomicassets.io'
FIREBASE_API_KEY='string'
FIREBASE_AUTH_DOMAIN='string'
FIREBASE_PROJECT_ID='string'
67 changes: 67 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"env": {
"browser": true,
"es2021": true,
"jest": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"plugin:react-hooks/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended" // keep this last so prettier config overrides other formatting rules
],
"plugins": [
"react"
],
"rules": {
"react-hooks/exhaustive-deps": "off",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"prettier/prettier": ["error", {}, { "usePrettierrc": true }], // Use our .prettierrc file as source
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], // ignore args with _ (needed for React.forwardRef fix
"jsx-a11y/accessible-emoji": "off",
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": ["Link"],
"specialLink": ["hrefLeft", "hrefRight"],
"aspects": ["invalidHref", "preferButton"]
}
],
"prefer-destructuring": ["error", {
"VariableDeclarator": {
"array": false,
"object": true
},
"AssignmentExpression": {
"array": true,
"object": true
}
}, {
"enforceForRenamedProperties": false
}]
},
"globals": {
"React": "writable"
},
"settings": {
"react": {
"version": "17.0.1"
}
}
}
19 changes: 19 additions & 0 deletions .github/workflows/merge-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: merge-request
on:
pull_request:
branches: [ master, develop ]
jobs:
typecheck:
name: Run Prettier, Linter, and Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: Install packages
run: yarn
- name: Prettier
run: yarn format
- name: Linter
run: yarn lint
- name: Typecheck
run: yarn typecheck
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# env files
.env
105 changes: 105 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
image: docker:18

variables:
GIT_SSL_NO_VERIFY: 1
DOCKER_DRIVER: overlay2
REPOSITORY_HOST: 830055101690.dkr.ecr.us-west-2.amazonaws.com
REPOSITORY_IMAGE: metal/proton-market
SERVICE_NAME: proton-market

stages:
- test
- build
- release

test:
image: nikolaik/python-nodejs
stage: test
only:
- merge_requests
script:
- yarn
- yarn format
- yarn typecheck
- yarn lint
- yarn build

build development:
stage: build
only:
- develop@proton/proton-market
services:
- docker:dind
before_script:
- docker info
- apk add --no-cache curl jq python py-pip
- pip install awscli yq
script:
- export IMAGE=devel-$CI_COMMIT_SHA
- $(aws ecr get-login --no-include-email --region us-west-2)
- docker build --no-cache
--build-arg NPM_TOKEN=${NPM_TOKEN}
--build-arg NEXT_PUBLIC_BLOCK_EXPLORER=${NEXT_PUBLIC_BLOCK_EXPLORER}
--build-arg NEXT_PUBLIC_CHAIN_ENDPOINTS=${NEXT_PUBLIC_CHAIN_ENDPOINTS}
--build-arg NEXT_PUBLIC_GA_TRACKING_ID=${NEXT_PUBLIC_GA_TRACKING_ID}
--build-arg NEXT_PUBLIC_NFT_ENDPOINT=${NEXT_PUBLIC_NFT_ENDPOINT}
- docker tag $REPOSITORY_IMAGE:latest $REPOSITORY_HOST/$REPOSITORY_IMAGE:latest
- docker tag $REPOSITORY_IMAGE:latest $REPOSITORY_HOST/$REPOSITORY_IMAGE:$IMAGE
- docker push $REPOSITORY_HOST/$REPOSITORY_IMAGE:latest
- docker push $REPOSITORY_HOST/$REPOSITORY_IMAGE:$IMAGE

build acceptance:
stage: build
only:
- /^release-.*/@proton/proton-market
variables:
DEPLOYMENT_ENVIRONMENT: "PRODUCTION"
services:
- docker:dind
before_script:
- docker info
- apk add --no-cache curl jq python py-pip
- pip install awscli yq
script:
- export IMAGE=$(cat package.json | jq .version -r)
- $(aws ecr get-login --no-include-email --region us-west-2)
- docker build --no-cache
--build-arg NPM_TOKEN=${NPM_TOKEN}
--build-arg NEXT_PUBLIC_BLOCK_EXPLORER=${NEXT_PUBLIC_BLOCK_EXPLORER}
--build-arg NEXT_PUBLIC_CHAIN_ENDPOINTS=${NEXT_PUBLIC_CHAIN_ENDPOINTS}
--build-arg NEXT_PUBLIC_GA_TRACKING_ID=${NEXT_PUBLIC_GA_TRACKING_ID}
--build-arg NEXT_PUBLIC_NFT_ENDPOINT=${NEXT_PUBLIC_NFT_ENDPOINT}
- docker tag $REPOSITORY_IMAGE:latest $REPOSITORY_HOST/$REPOSITORY_IMAGE:latest
- docker tag $REPOSITORY_IMAGE:latest $REPOSITORY_HOST/$REPOSITORY_IMAGE:$IMAGE
- docker push $REPOSITORY_HOST/$REPOSITORY_IMAGE:latest
- docker push $REPOSITORY_HOST/$REPOSITORY_IMAGE:$IMAGE

update development helm chart:
image: 830055101690.dkr.ecr.us-west-2.amazonaws.com/metal/ci:latest
stage: release
only:
- develop@proton/proton-market
script:
- export IMAGE=devel-$CI_COMMIT_SHA
- git clone -b develop [email protected]:metalpay/metal-devops.git
- cd metal-devops/helm/proton
- touch values-development.yaml
- cat values-development.yaml | yq '."'$SERVICE_NAME'".image.tag="'$IMAGE'"' -y > new-values.yaml
- mv -f new-values.yaml values-development.yaml
- git add values-development.yaml
- if [[ -z $(git status -s) ]]; then echo 'Tree is clean'; else git commit -m "Update $SERVICE_NAME image tag to $IMAGE"; git push; fi

update acceptance helm chart:
image: 830055101690.dkr.ecr.us-west-2.amazonaws.com/metal/ci:latest
stage: release
only:
- /^release-.*/@proton/proton-market
script:
- export IMAGE=$(cat package.json | jq .version -r)
- git clone -b develop [email protected]:metalpay/metal-devops.git
- cd metal-devops/helm/proton
- touch values-acceptance.yaml
- cat values-acceptance.yaml | yq '."'$SERVICE_NAME'".image.tag="'$IMAGE'"' -y > new-values.yaml
- mv -f new-values.yaml values-acceptance.yaml
- git add values-acceptance.yaml
- if [[ -z $(git status -s) ]]; then echo 'Tree is clean'; else git commit -m "Update $SERVICE_NAME image tag to $IMAGE"; git push; fi
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
singleQuote: true,
jsxBracketSameLine: true,
semi: true,
};
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:14-alpine

ARG NPM_TOKEN
ARG NEXT_PUBLIC_GA_TRACKING_ID
ARG NEXT_PUBLIC_CHAIN_ENDPOINTS
ARG NEXT_PUBLIC_BLOCK_EXPLORER
ARG NEXT_PUBLIC_NFT_ENDPOINT
ENV NEXT_PUBLIC_CHAIN_ENDPOINTS=$NEXT_PUBLIC_CHAIN_ENDPOINTS
ENV NEXT_PUBLIC_BLOCK_EXPLORER=$NEXT_PUBLIC_BLOCK_EXPLORER
ENV NEXT_PUBLIC_GA_TRACKING_ID=$NEXT_PUBLIC_GA_TRACKING_ID
ENV NEXT_PUBLIC_NFT_ENDPOINT=$NEXT_PUBLIC_NFT_ENDPOINT

# COPY .npmrc .npmrc
COPY package.json .
COPY components components
COPY hooks hooks
COPY pages pages
COPY public public
COPY services services
COPY styles styles
COPY types types
COPY utils utils
COPY tsconfig.json .
COPY next.config.js .
COPY next-env.d.ts .
COPY babel.config.json .
COPY .prettierrc.js .
COPY .eslintrc.json .
COPY server.js .
RUN npm i && npm run build

EXPOSE 3000

CMD [ "npm", "run", "start" ]
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

# Proton Marketplace

This application shows the basic functionality of NFTs on the Proton chain through the use of the [Proton Web SDK](https://www.npmjs.com/package/@proton/web-sdk).

This is built off of atomicassets NFT framework.

- [API Documentation for atomicassets (mainnet)](https://proton.api.atomicassets.io/atomicassets/docs/swagger/)
- [API Documentation for atomicmarket (mainnet)](https://proton.api.atomicassets.io/atomicmarket/docs/swagger/)
- [API Documentation for atomicassets (testnet)](https://test.proton.api.atomicassets.io/atomicassets/docs/swagger/)
- [API Documentation for atomicmarket (testnet)](https://test.proton.api.atomicassets.io/atomicmarket/docs/swagger/)

## To build and run locally

### Docker

Run a docker container:

```
docker build nft-demo .
docker images
docker run -p 3000:3000 -i -d [image id]
```

### npm

```
git clone https://github.com/ProtonProtocol/nft-demo.git
npm install
npm run dev
```

## Environment

Create a copy of `.env.template` and name it `.env.local`:

For mainnet:
```
NEXT_PUBLIC_CHAIN_ENDPOINTS='https://proton.eoscafeblock.com, https://proton.greymass.com'
NEXT_PUBLIC_BLOCK_EXPLORER='https://proton.bloks.io/block/'
NEXT_PUBLIC_NFT_ENDPOINT='https://proton.api.atomicassets.io'
```

For testnet:
```
NEXT_PUBLIC_CHAIN_ENDPOINTS='https://testnet.protonchain.com'
NEXT_PUBLIC_BLOCK_EXPLORER='https://proton-test.bloks.io/block/'
NEXT_PUBLIC_NFT_ENDPOINT='https://test.proton.api.atomicassets.io'
```

## Marketplace

The marketplace page consists of templates of a specific `collection_name`.

### Custom flags

- The `Template` object is extended with the following custom property: `lowestPrice`.
- `lowestPrice` (string) is determined by checking the Sales API for assets listed for sale and finding the lowest price of the assets of that particular template.

## My NFTs

The `My NFTs` page consists of the current user's assets. Each user is only allowed to view their own collection page in this demo.

### Custom flags

- The `Asset` object is extended with the following custom properties: `isForSale` and `salePrice`.
- `isForSale` (boolean) is determined by checking the Sales API for currently listed sales using the `asset_id` and `seller` (current user's `chainAccount`)
- `salePrice` (string) is determined by checking the Sales API and combining an asset's `listing_price` and `listing_symbol`
15 changes: 15 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"presets": [
"next/babel"
],
"plugins": [
[
"styled-components",
{
"ssr": true,
"displayName": true,
"preprocess": true
}
]
]
}
Loading

0 comments on commit a3a4968

Please sign in to comment.