GithubHelp home page GithubHelp logo

flow-pds's Introduction

Flow Pack Distribution Service

Running the PDS backend service

Docker

cp env.example .env # edit according to your setup
docker run -p 3000:3000 --env-file .env ghcr.io/flow-hydraulics/flow-pds:latest

Dev environment

cp env.example .env

# Needs docker-compose installed
make dev

Deployment notes

NOTE: Currently the PDS backend only supports a single instance setup. This is because of sequence number bookkeeping in service/flow_helpers/account.go (see getSequenceNumber).

Testing

cp env.example .env.test

# Standalone (can NOT have emulator running in docker)
./tests-with-emulator.sh

# With docker-compose environment ("make dev" above)
go test -v

Project layout

Backend service code: ./service

Contract code (test, deploy): ./go-contracts

API spec:

  • ./models
  • ./reference

Simple API tests: ./api-scripts

Cadence source code:

  • ./cadence-contracts
  • ./cadence-scripts
  • ./cadence-transactions

Configuration

Database

Config variable Environment variable Description Default Examples
DatabaseType FLOW_PDS_DATABASE_DSN Type of database driver sqlite sqlite, psql, mysql
DatabaseDSN FLOW_PDS_DATABASE_TYPE Data source name (DSN) for database connection pds.db See below

Examples of Database DSN

mysql://john:pass@localhost:3306/my_db

postgresql://postgres:postgres@localhost:5432/postgres

user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local

host=localhost user=gorm password=gorm dbname=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai

For more: https://gorm.io/docs/connecting_to_the_database.html

Google KMS admin key

In order to use a key stored in Google KMS as admin key:

  • first create the key in Google KMS
  • export the public key & resource name
  • convert the key using flow-cli (flow keys decode pem --from-file kms-key-export.pem)
  • add the key to the PDS account (for testing in emulator; flow transactions send ./cadence-transactions/keys/add-key.cdc <public key> --signer emulator-pds)
    • when testing locally the added key will usually be in index 1, remember to update FLOW_PDS_ADMIN_PRIVATE_KEY_INDEXES accordingly
  • modify the following configuration settings:
Config variable Environment variable Description Default Examples
AdminPrivateKey FLOW_PDS_ADMIN_PRIVATE_KEY Private key value, for Google KMS this should be the Resource Name of the key "" projects/KMS_PROJECT_NAME/locations/KMS_PROJECT_LOCATION/keyRings/KMS_KEYRING_NAME/cryptoKeys/KMS_ADMIN_KEY_NAME/cryptoKeyVersions/1, 9c687961e7a1abe1e445830e7ec118ffd1e2a0449cf705f5476b3f100e94dc29
AdminPrivateKeyIndexes FLOW_PDS_ADMIN_PRIVATE_KEY_INDEXES Comma separated list of key indexes that can be used. 0 1,2,3
AdminPrivateKeyType FLOW_PDS_ADMIN_PRIVATE_KEY_TYPE Type of key, google_kms for Google KMS local local, google_kms
- GOOGLE_APPLICATION_CREDENTIALS Path the the Google KMS credentials JSON file. /path/to/kms-credentials.json

All possible configuration variables

Refer to service/config/config.go for details and documentation.

flow-pds's People

Contributors

aphelionz avatar fkenji avatar latenssi avatar nanuuki avatar sadief avatar whalelephant avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.