Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup the initial version #1

Merged
merged 28 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
66b9822
develop: setup the initial version
forcodedancing Oct 10, 2023
b217e9d
add config for start height
forcodedancing Oct 10, 2023
f2e1b4a
refine configs
forcodedancing Oct 10, 2023
b02610c
add readme
forcodedancing Oct 10, 2023
3501e68
add some metrics
forcodedancing Oct 10, 2023
0355c2a
fix dockerfile
forcodedancing Oct 10, 2023
6a0199a
fix dockerfile
forcodedancing Oct 10, 2023
545e4cd
fix dockerfile
forcodedancing Oct 10, 2023
3210bff
fix dockerfile
forcodedancing Oct 10, 2023
1991799
add some sleep
forcodedancing Oct 10, 2023
688e184
change host in dockfile
forcodedancing Oct 10, 2023
60af847
add curl to image
forcodedancing Oct 11, 2023
132b453
fix a monitor issue
forcodedancing Oct 11, 2023
4bbf1b7
add more fields to api
forcodedancing Oct 11, 2023
92ee2cc
update swaggger url
forcodedancing Oct 11, 2023
43a7bb9
fix a query
forcodedancing Oct 11, 2023
1e77a47
update cors for options
forcodedancing Oct 11, 2023
3043634
add api
forcodedancing Oct 11, 2023
82d01a1
fix a query
forcodedancing Oct 11, 2023
98c22fc
add more fields to api
forcodedancing Oct 13, 2023
84276f6
add list time, purchase time
forcodedancing Oct 13, 2023
082697f
update server to use the new time fields
forcodedancing Oct 13, 2023
ab17233
refine event parse
forcodedancing Oct 16, 2023
ce74497
add list event
forcodedancing Oct 16, 2023
beb1cdf
do not update status when put policy
forcodedancing Oct 18, 2023
cb54a91
to support multi contracts
forcodedancing Oct 18, 2023
30ae7b5
rename project
forcodedancing Oct 19, 2023
813589a
refine codes
forcodedancing Oct 19, 2023
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
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Report a bug
about: Something with greenfield-relayer is not working as expected
title: ''
labels: 'type:bug'
assignees: ''
---

#### System information

Relayer version: (if getting from release page)
OS & Version: Windows/Linux/OSX
Commit hash : (if `develop`)

#### Expected behaviour


#### Actual behaviour


#### Steps to reproduce the behaviour


#### Backtrace

````
[backtrace]
````

When submitting logs: please submit them as text and not screenshots.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Request a feature
about: Report a missing feature - e.g. as a step before submitting a PR
title: ''
labels: 'type:feature'
assignees: ''
---

# Rationale

Why should this feature exist?
What are the use-cases?

# Implementation

Do you have ideas regarding the implementation of this feature?
Are you willing to implement this feature?
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: Ask a question
about: Something is unclear
title: ''
labels: 'type:docs'
assignees: ''
---

This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation. For general questions please use [discord](https://discord.gg/bnbchain).
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Description

add a description of your changes here...

### Rationale

tell us why we need these changes...

### Example

add an example CLI or API response...

### Changes

Notable changes:
* add each change in a bullet point here
* ...
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Test

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
build-test:
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
GOPRIVATE: github.com/bnb-chain
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3

- uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Setup GitHub Token
run: git config --global url.https://[email protected]/.insteadOf https://github.com/

- name: Test Build
run: |
make build
56 changes: 56 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Docker

on:
push:
# Publish `v1.2.3` tags as releases.
tags:
- v*

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
IMAGE_SOURCE: https://github.com/${{ github.repository }}

jobs:
# Push image to GitHub Packages.
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v3

- name: Build image
run: |
docker build . \
--label "org.opencontainers.image.source=${IMAGE_SOURCE}" \
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
--label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \
-f ./server-distroless.dockerfile -t "${IMAGE_NAME}:server-distroless"

docker build . \
--label "org.opencontainers.image.source=${IMAGE_SOURCE}" \
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
--label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \
-f ./monitor-distroless.dockerfile -t "${IMAGE_NAME}:monitor-distroless"

- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
docker tag ${IMAGE_NAME}:server-distroless $IMAGE_NAME:$VERSION-server-distroless
docker tag ${IMAGE_NAME}:monitor-distroless $IMAGE_NAME:$VERSION-monitor-distroless
docker push $IMAGE_NAME:$VERSION-server-distroless
docker push $IMAGE_NAME:$VERSION-monitor-distroless
51 changes: 51 additions & 0 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: gosec

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
gosec:
name: gosec
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
GOPRIVATE: github.com/bnb-chain
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- name: Setup GitHub Token
run: git config --global url.https://[email protected]/.insteadOf https://github.com/
- uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: |
go mod tidy
go mod download
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: -quiet -confidence high -severity high ./...
30 changes: 30 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
release
55 changes: 55 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Lint
on:
push:
branches:
- master
- develop
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: golangci-lint
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
GOPRIVATE: github.com/bnb-chain
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3

- run: go env -w GOPRIVATE="github.com/bnb-chain/*"
- run: git config --global url."https://${{ secrets.GH_TOKEN }}@github.com".insteadOf "https://github.com"

- uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: |
go mod tidy
go mod download
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
skip-pkg-cache: true
args: --timeout=99m
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@

# Go workspace file
go.work

.idea

# Local configrations
config

build
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
BUILD_TAGS = netgo
PACKAGES=$(shell go list ./dao ./service ./monitor/.)

build_monitor:
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/monitor.exe cmd/mind-marketplace-monitor/main.go
else
go build $(BUILD_FLAGS) -o build/monitor cmd/mind-marketplace-monitor/main.go
endif

#build_monitor_docker:
# docker build --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} -f monitor.dockerfile -t monitor .

build_server:
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/server.exe cmd/mind-marketplace-server/main.go
else
go build $(BUILD_FLAGS) -o build/server cmd/mind-marketplace-server/main.go
endif

#build_server_docker:
# docker build --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} -f server.dockerfile -t server .

build: build_server build_monitor

#build_docker: build_server_docker build_monitor_docker

test:
go test -race -v $(PACKAGES)

lint:
golangci-lint cache clean
golangci-lint run

genswagger:
swagger generate server -f ./swagger.yaml -A mind-marketplace --default-scheme=http

genabi:
./script/abigen --abi ./monitor/contracts/marketplace.abi --pkg contracts --out ./monitor/contracts/marketplace.go --type Marketplace


.PHONY: build build_docker test lint genswagger genabi
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# mind-marketplace-backend

The backend service for greenfield data marketplace. There are two main components:
* monitor: indexing blocks of greenfield and bsc,
* server: providing apis.

Loading