-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from DaoCasino/develop
v1.0.0
- Loading branch information
Showing
11 changed files
with
581 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# use the latest ubuntu environment (18.04) available on travis | ||
dist: bionic | ||
|
||
language: go | ||
go: | ||
- 1.13.4 | ||
|
||
services: | ||
- docker | ||
|
||
env: | ||
- IMG_NAME=daocasino/casinoback DOCKER_TAG_LATEST=true DOCKER_REGISTRY=registry.hub.docker.com | ||
|
||
before_install: | ||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
|
||
cache: | ||
directories: | ||
- $HOME/.ccache | ||
timeout: 1000 | ||
|
||
# Only clone the most recent commit. | ||
git: | ||
depth: 1 | ||
|
||
|
||
# Don't email me the results of the test runs. | ||
notifications: | ||
email: false | ||
|
||
# Anything in before_script that returns a nonzero exit code will flunk the | ||
# build and immediately stop. It's sorta like having set -e enabled in bash. | ||
# We can download and extract the golangci-lint binary in one (long) command. | ||
before_script: | ||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin v1.23.1 | ||
|
||
# script always runs to completion (set +e). If we have linter issues AND a | ||
# failing test, we want to see both. Configure golangci-lint with a | ||
# .golangci.yml file at the top level of your repo. | ||
jobs: | ||
include: | ||
- stage: lint & test | ||
script: | ||
- golangci-lint run | ||
- go test -v -race -coverprofile=coverage.txt -covermode=atomic . | ||
- stage: build & push | ||
script: | ||
- docker build -t $IMG_NAME:$TRAVIS_BRANCH -f Dockerfile . | ||
- | | ||
docker push $IMG_NAME:$TRAVIS_BRANCH | ||
if [ $TRAVIS_BRANCH == "master" ]; then | ||
docker tag $IMG_NAME:master $IMG_NAME:latest | ||
docker push $IMG_NAME:latest | ||
fi | ||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM golang:latest AS builder | ||
ENV GO111MODULE=on | ||
RUN mkdir -p /build | ||
ADD . /build | ||
WORKDIR /build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o casino . | ||
|
||
FROM alpine:latest | ||
RUN apk --no-cache add ca-certificates | ||
COPY --from=builder /build/casino /usr/bin | ||
CMD ["casino"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
# Casino Backend | ||
|
||
## Build Status | ||
|
||
Branch|Build Status | ||
---|--- | ||
Master|[![master](https://travis-ci.org/DaoCasino/casino-backend?branch=master)](https://travis-ci.org/DaoCasino/casino-backend) | ||
Develop|[![develop](https://travis-ci.org/DaoCasino/casino-backend?branch=develop)](https://travis-ci.org/DaoCasino/casino-backend) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/eoscanada/eos-go" | ||
) | ||
|
||
func NewSigndice(contract, casinoAccount string, requestID uint64, signature string) *eos.Action { | ||
return &eos.Action{ | ||
Account: eos.AN(contract), | ||
Name: eos.ActN("sgdicesecond"), | ||
Authorization: []eos.PermissionLevel{ | ||
{Actor: eos.AN(casinoAccount), Permission: eos.PN("signidice")}, | ||
}, | ||
ActionData: eos.NewActionData(Signidice{ | ||
requestID, | ||
signature, | ||
}), | ||
} | ||
} | ||
|
||
// Game contract's sgdicesecond action parameters | ||
type Signidice struct { | ||
RequestID uint64 `json:"req_id"` | ||
Signature string `json:"sign"` | ||
} | ||
|
||
|
||
func GetSigndiceTransaction(api *eos.API, contract, casinoAccount string,requestID uint64, signature string) (*eos.SignedTransaction, *eos.PackedTransaction, error) { | ||
action := NewSigndice(contract, casinoAccount, requestID, signature) | ||
txOpts := &eos.TxOptions{} | ||
|
||
if err := txOpts.FillFromChain(api); err != nil { | ||
return nil, nil, err | ||
} | ||
tx := eos.NewTransaction([]*eos.Action{action}, txOpts) | ||
signedTx, packedTx, err := api.SignTransaction(tx, txOpts.ChainID, eos.CompressionNone) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
return signedTx, packedTx, nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
module github.com/DaoCasino/casino-backend | ||
|
||
go 1.12 | ||
go 1.13 | ||
|
||
require ( | ||
github.com/BurntSushi/toml v0.3.1 | ||
github.com/eoscanada/eos-go v0.9.0 | ||
github.com/gorilla/mux v1.7.4 | ||
github.com/kelseyhightower/envconfig v1.4.0 | ||
github.com/rs/zerolog v1.18.0 | ||
github.com/stretchr/testify v1.4.0 | ||
github.com/BurntSushi/toml v0.3.1 | ||
github.com/DaoCasino/platform-action-monitor-client v0.0.0-20200413133148-52406924efbc | ||
github.com/eoscanada/eos-go v0.9.0 | ||
github.com/gorilla/mux v1.7.4 | ||
github.com/kelseyhightower/envconfig v1.4.0 | ||
github.com/rs/zerolog v1.18.0 | ||
github.com/stretchr/testify v1.5.1 | ||
github.com/zenazn/goji v0.9.0 | ||
) |
Oops, something went wrong.