Skip to content

Commit

Permalink
[Relay] Improve payment information using royalties to be stored in t…
Browse files Browse the repository at this point in the history
…he database
  • Loading branch information
MichaelKim20 committed Nov 6, 2023
1 parent a34c268 commit aadb064
Show file tree
Hide file tree
Showing 25 changed files with 1,038 additions and 133 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ jobs:
with:
cache: 'yarn'
node-version: ${{ matrix.node-version }}

- name: Setup MySQL 8.0
uses: ankane/setup-mysql@v1
with:
mysql-version: 8.0
database: relay

- name: Config MySQL
run: |
mysqladmin -u root password '12345678'
exit;
- name: Install dependencies
run: yarn install --pure-lockfile
- name: Check formatting of Contract
Expand Down
31 changes: 0 additions & 31 deletions packages/relay/config/config.example.yaml

This file was deleted.

39 changes: 26 additions & 13 deletions packages/relay/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,22 @@
################################################################################
server:
# Address to which we bind (default: 127.0.0.1)
address: ${HOST_IP}
address: "${HOST_IP}"
# Port on which we bind (default: 3000)
port: ${HOST_PORT}
port: "${HOST_PORT}"

################################################################################
## Database options ##
################################################################################
database:
host: "${DATABASE_HOST}"
user: "${DATABASE_USER}"
database: "${DATABASE_NAME}"
password: "${DATABASE_PASSWORD}"
port: "${DATABASE_PORT}"
waitForConnections: true
connectionLimit: 30
queueLimit: 0

################################################################################
## Logging options ##
Expand All @@ -20,16 +33,16 @@ logging:

relay:
managerKeys:
- ${MANAGER_KEY1}
- ${MANAGER_KEY2}
- ${MANAGER_KEY3}
- ${MANAGER_KEY4}
- ${MANAGER_KEY5}
accessKey: ${ACCESS_KEY}
certifier: ${CERTIFIER_KEY}
- "${MANAGER_KEY1}"
- "${MANAGER_KEY2}"
- "${MANAGER_KEY3}"
- "${MANAGER_KEY4}"
- "${MANAGER_KEY5}"
accessKey: "${ACCESS_KEY}"
certifier: "${CERTIFIER_KEY}"

contracts:
tokenAddress : ${TOKEN_CONTRACT_ADDRESS}
ledgerAddress : ${LEDGER_CONTRACT_ADDRESS}
phoneLinkerAddress : ${PHONE_LINKER_CONTRACT_ADDRESS}
shopAddress : ${SHOP_CONTRACT_ADDRESS}
tokenAddress : "${TOKEN_CONTRACT_ADDRESS}"
ledgerAddress : "${LEDGER_CONTRACT_ADDRESS}"
phoneLinkerAddress : "${PHONE_LINKER_CONTRACT_ADDRESS}"
shopAddress : "${SHOP_CONTRACT_ADDRESS}"
39 changes: 26 additions & 13 deletions packages/relay/config/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,22 @@
################################################################################
server:
# Address to which we bind (default: 127.0.0.1)
address: "0.0.0.0"
address: "${HOST_IP}"
# Port on which we bind (default: 3000)
port: 3001
port: "${HOST_PORT}"

################################################################################
## Database options ##
################################################################################
database:
host: "${DATABASE_HOST}"
user: "${DATABASE_USER}"
database: "${DATABASE_NAME}"
password: "${DATABASE_PASSWORD}"
port: "${DATABASE_PORT}"
waitForConnections: true
connectionLimit: 30
queueLimit: 0

################################################################################
## Logging options ##
Expand All @@ -20,16 +33,16 @@ logging:

relay:
managerKeys:
- ${MANAGER_KEY1}
- ${MANAGER_KEY2}
- ${MANAGER_KEY3}
- ${MANAGER_KEY4}
- ${MANAGER_KEY5}
accessKey: ${ACCESS_KEY}
certifier: ${CERTIFIER_KEY}
- "${MANAGER_KEY1}"
- "${MANAGER_KEY2}"
- "${MANAGER_KEY3}"
- "${MANAGER_KEY4}"
- "${MANAGER_KEY5}"
accessKey: "${ACCESS_KEY}"
certifier: "${CERTIFIER_KEY}"

contracts:
tokenAddress : ${TOKEN_CONTRACT_ADDRESS}
ledgerAddress : ${LEDGER_CONTRACT_ADDRESS}
phoneLinkerAddress : ${PHONE_LINKER_CONTRACT_ADDRESS}

tokenAddress : "${TOKEN_CONTRACT_ADDRESS}"
ledgerAddress : "${LEDGER_CONTRACT_ADDRESS}"
phoneLinkerAddress : "${PHONE_LINKER_CONTRACT_ADDRESS}"
shopAddress : "${SHOP_CONTRACT_ADDRESS}"
27 changes: 12 additions & 15 deletions packages/relay/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
version: '3.3'

services:
dms-osx-relay:
image: bosagora/dms-osx-relay:latest
container_name: dms-osx-relay
mysql:
image: "mysql:8.0"
cap_add:
- SYS_NICE
ports:
- '3000:3000'
- "3306:3306"
command: --default-authentication-plugin=mysql_native_password
restart: always
extra_hosts:
- host.docker.internal:host-gateway
volumes:
- mysql_db:/var/lib/mysql
environment:
PRODUCTION_NET_URL: http://host.docker.internal:8545
PRODUCTION_CHAIN_ID: 24680
HOST_IP: 0.0.0.0
HOST_PORT: 3000
networks:
- default_network
MYSQL_ROOT_PASSWORD: "12345678"

networks:
default_network:
driver: bridge
volumes:
mysql_db:
7 changes: 7 additions & 0 deletions packages/relay/env/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ TEST_NET_URL=https://testnet.bosagora.org
PRODUCTION_NET_URL=http://localhost:8545
PRODUCTION_CHAIN_ID=24680

# DATABASE INFO
DATABASE_HOST=127.0.0.1
DATABASE_USER=root
DATABASE_NAME=relay
DATABASE_PASSWORD=12345678
DATABASE_PORT=3306

# 0xDc245797409fb79446523Fa1A4ca97294eef22EE
DEPLOYER=0x2b5d5cc406b66c0398d0b8327d340cb4f6e30540621802e115506fe001398ba3

Expand Down
8 changes: 6 additions & 2 deletions packages/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@
"@types/mocha": "^10.0.0",
"@types/node": "^12.20.43",
"@types/node-cron": "^3.0.1",
"@types/urijs": "^1.19.12",
"@types/urijs": "^1.19.12"
},
"dependencies": {
"argparse": "^2.0.1",
"assert": "^2.0.0",
"axios": "^0.26.0",
"body-parser": "^1.19.0",
"chai": "^4.3.7",
"chai-http": "^4.3.7",
"cors": "^2.8.5",
"del-osx-artifacts": "^1.1.1",
"dms-osx-artifacts": "^1.1.7",
"dotenv": "^10.0.0",
"ethereum-waffle": "^4.0.10",
Expand All @@ -69,8 +72,9 @@
"hardhat": "^2.12.7",
"hardhat-gas-reporter": "^1.0.7",
"ip": "^1.1.5",
"del-osx-artifacts": "^1.1.1",
"moment": "^2.29.1",
"mybatis-mapper": "^0.7.1",
"mysql2": "^3.6.3",
"prettier": "^2.5.1",
"prettier-plugin-solidity": "^1.1.1",
"smart-buffer": "^4.1.0",
Expand Down
13 changes: 8 additions & 5 deletions packages/relay/src/DefaultServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ShopRouter } from "./routers/ShopRouter";
import { WebService } from "./service/WebService";

import { RelaySigners } from "./contract/Signers";
import { RelayStorage } from "./storage/RelayStorage";

export class DefaultServer extends WebService {
/**
Expand All @@ -22,20 +23,22 @@ export class DefaultServer extends WebService {
public readonly shopRouter: ShopRouter;
public readonly paymentRouter: PaymentRouter;
public readonly relaySigners: RelaySigners;
public readonly storage: RelayStorage;

/**
* Constructor
* @param config Configuration
*/
constructor(config: Config) {
constructor(config: Config, storage: RelayStorage) {
super(config.server.port, config.server.address);

this.config = config;
this.storage = storage;
this.relaySigners = new RelaySigners(this.config);
this.defaultRouter = new DefaultRouter(this, this.config, this.relaySigners);
this.ledgerRouter = new LedgerRouter(this, this.config, this.relaySigners);
this.shopRouter = new ShopRouter(this, this.config, this.relaySigners);
this.paymentRouter = new PaymentRouter(this, this.config, this.relaySigners);
this.defaultRouter = new DefaultRouter(this, this.config, this.storage, this.relaySigners);
this.ledgerRouter = new LedgerRouter(this, this.config, this.storage, this.relaySigners);
this.shopRouter = new ShopRouter(this, this.config, this.storage, this.relaySigners);
this.paymentRouter = new PaymentRouter(this, this.config, this.storage, this.relaySigners);
}

/**
Expand Down
Loading

0 comments on commit aadb064

Please sign in to comment.