Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Feb 17, 2022
2 parents d832283 + 5ee2554 commit e14f4b7
Show file tree
Hide file tree
Showing 38 changed files with 639 additions and 245 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ HAPI_AFFILIATE_PASSWORD=PW...
HAPI_AFFILIATE_VERIFY_EXPIRED_INTERVAL=3600
HAPI_AFFILIATE_CLEAR_REFERRALS_INTERVAL=86400
HAPI_AFFILIATE_SET_RATE_INTERVAL=86400
HAPI_AFFILIATE_UPDATE_KYC_INTERVAL=18000
HAPI_AFFILIATE_UPDATE_REQUESTER_INTERVAL=86400
HAPI_HYPERION_API=https://testnet.protonchain.com
HAPI_HYPERION_START_AT=2021-06-02T00:00:00.000+00:00
HAPI_EXCHANGE_API=https://api.coingecko.com/api/v3/simple/price?ids=(from)&vs_currencies=(to)
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/push-dev-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
HAPI_AFFILIATE_VERIFY_EXPIRED_INTERVAL: 3600
HAPI_AFFILIATE_CLEAR_REFERRALS_INTERVAL: 86400
HAPI_AFFILIATE_SET_RATE_INTERVAL: 86400
HAPI_AFFILIATE_UPDATE_KYC_INTERVAL: 18000
HAPI_AFFILIATE_UPDATE_REQUESTER_INTERVAL: 86400
HAPI_HYPERION_API: 'https://testnet.protonchain.com'
HAPI_HYPERION_START_AT: '2021-06-02T00:00:00.000+00:00'
HAPI_EXCHANGE_API: 'https://api.coingecko.com/api/v3/simple/price?ids=(from)&vs_currencies=(to)'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/push-prod-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
HAPI_AFFILIATE_VERIFY_EXPIRED_INTERVAL: 3600
HAPI_AFFILIATE_CLEAR_REFERRALS_INTERVAL: 86400
HAPI_AFFILIATE_SET_RATE_INTERVAL: 86400
HAPI_AFFILIATE_UPDATE_KYC_INTERVAL: 18000
HAPI_AFFILIATE_UPDATE_REQUESTER_INTERVAL: 86400
HAPI_HYPERION_API: ${{ secrets.HAPI_HYPERION_API }}
HAPI_HYPERION_START_AT: '2021-06-02T00:00:00.000+00:00'
HAPI_EXCHANGE_API: 'https://api.coingecko.com/api/v3/simple/price?ids=(from)&vs_currencies=(to)'
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Contributing to EOS Costa Rica's Open Source Projects
👍🎉 First off, thanks for taking the time to contribute! 🎉👍
# Contributing to Edenia's Open Source Projects

The following is a set of guidelines for contributing to EOS Costa Rica's Open Source Projects and its packages, which are hosted in the [`eoscostarica`](https://github.com/eoscostarica/) Organization on GitHub.
👍🎉 First off, thanks for taking the time to contribute! 🎉👍

The following is a set of guidelines for contributing to Edenia's Open Source Projects and its packages, which are hosted in the [`eoscostarica`](https://github.com/eoscostarica/) Organization on GitHub.

### [View Open Source Contributing Guidelines](https://guide.eoscostarica.io/docs/open-source-guidelines)

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 EOS Costa Rica
Copyright (c) 2022 Sistemas Edenia Internacional S.A.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
55 changes: 33 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,44 @@
</p>

# Proton Affiliate Platform

**An on-chain affiliate marketing platform, rewarding users in XPR for referring and registering on Proton.**

![](https://img.shields.io/github/license/eoscostarica/proton-affiliate) ![](https://img.shields.io/badge/code%20style-standard-brightgreen.svg) ![](https://img.shields.io/badge/%E2%9C%93-collaborative_etiquette-brightgreen.svg) ![](https://img.shields.io/twitter/follow/eoscostarica.svg?style=social&logo=twitter) ![](https://img.shields.io/github/forks/eoscostarica/proton-affiliate?style=social)

### Production Instance: [earnproton.com](https://earnproton.com)

Proton mainnet instance deploys the `main` branch of this repository.

### Development Instance: [test.earnproton.com](https://test.earnproton.com)

Proton testnet instance deploys the `dev` branch of this repository.

## Table of Contents

- [Tech Stack](#tech-stack)
- [Smart Contract](#smart-contract)
- [Demux Pattern](#demux-pattern)
- [Proton Affiliate Platform](#proton-affiliate-platform)
- [Production Instance: earnproton.com](#production-instance-earnprotoncom)
- [Development Instance: test.earnproton.com](#development-instance-testearnprotoncom)
- [Table of Contents](#table-of-contents)
- [Tech Stack](#tech-stack)
- [Smart Contract](#smart-contract)
- [Smart Contract Docs](#smart-contract-docs)
- [Demux Pattern](#demux-pattern)
- [Services Using Demux](#services-using-demux)
- [Demux Data Flow](#demux-data-flow)
- [Installation](#installation)
- [Before you Start](#before-you-start)
- [First Time](#first-time)
- [Quick Start](#quick-start)
- [File Structure](#file-structure)
- [Technical Documentation](#technical-documentation)
- [Infrastructure Diagram](#infrastructure-diagram)
- [Web Application](#web-application)
- [Hapi REST Server](#hapi-rest-server)
- [Hasura GraphQL Engine](#hasura-graphql-engine)
- [EOSIO Blockchain Integration](#eosio-blockchain-integration)
- [EOSIO Blockchain Integration](#eosio-blockchain-integration)
- [Web Application](#web-application)
- [Hasura GraphQL Engine](#hasura-graphql-engine)
- [Hapi REST Server](#hapi-rest-server)
- [License](#license)
- [Contributing](#contributing)
- [Contributors](#contributors)
- [About EOS Costa Rica](#about-eos-costa-rica)
- [About Edenia](#about-edenia)

## Tech Stack

Expand All @@ -44,7 +55,7 @@ This application features the following tech stack :
- **Kubernetes** : Docker Container Orchestration.

<p align="center">
<img src="./docs/img/services.png">
<img src="./docs/img/tech-stack.png">
</p>

## Smart Contract
Expand Down Expand Up @@ -121,10 +132,10 @@ Within this repository you will find the following directories and files:
│   └── affiliate ................. Affiliate Platform Contract
├── docs .......................... Documentation
│   └── img ....................... Images and Diagrams
├── hapi .......................... Node JS backend & HTTP API
│   └── src
├── hapi .......................... Node JS backend & HTTP API
│   └── src
│   └── config ................ Backend Configurations
│   └── routes ................ HTTP routes
│   └── routes ................ HTTP routes
│   └── utils ................. Utilities and Libraries
│   └── services .............. Project Business Logic
| └── hyperion .......... Demux Implementation
Expand Down Expand Up @@ -160,23 +171,23 @@ We need to handle REST custom requests coming from the Hasura GraphQL server. Fo

# License

MIT © [EOS Costa Rica](https://eoscostarica.io).
MIT © [Sistemas Edenia Internacional S.A.](https://edenia.com).

# Contributing

Please read EOS Costa Rica's [Open Source Contributing Guidelines](https://developers.eoscostarica.io/docs/open-source-guidelines).
Please read Edenia's [Open Source Contributing Guidelines](https://developers.eoscostarica.io/docs/open-source-guidelines).

Please report bugs big and small by [opening an issue](https://github.com/eoscostarica/proton-affiliate/issues)
Please report bugs big and small by [opening an issue](https://github.com/edenia/proton-affiliate/issues/new/choose)

## About EOS Costa Rica
## About Edenia

<p align="center">
<a href="https://eoscostarica.io">
<img src="https://github.com/eoscostarica/eos-rate/raw/master/docs/eoscostarica-logo-black.png" width="300">
<a href="https://edenia.com">
<img src="https://earnproton.com/edenia.png" width="300">
</a>
</p>
<br/>

EOS Costa Rica is an independently-owned, self-funded, bare-metal Genesis block producer that provides stable and secure infrastructure for EOSIO blockchains. We support open source software for our community while offering enterprise solutions and custom smart contract development for our clients.
Edenia runs independent blockchain infrastructure and develops web3 solutions. Our team of technology-agnostic builders has been operating since 1987, leveraging the newest technologies to make the internet safer, more efficient, and more transparent.

[eoscostarica.io](https://eoscostarica.io)
[edenia.com](https://edenia.com/)
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ services:
HAPI_AFFILIATE_VERIFY_EXPIRED_INTERVAL: '${HAPI_AFFILIATE_VERIFY_EXPIRED_INTERVAL}'
HAPI_AFFILIATE_CLEAR_REFERRALS_INTERVAL: '${HAPI_AFFILIATE_CLEAR_REFERRALS_INTERVAL}'
HAPI_AFFILIATE_SET_RATE_INTERVAL: '${HAPI_AFFILIATE_SET_RATE_INTERVAL}'
HAPI_AFFILIATE_UPDATE_KYC_INTERVAL: '${HAPI_AFFILIATE_UPDATE_KYC_INTERVAL}'
HAPI_AFFILIATE_UPDATE_REQUESTER_INTERVAL: '${HAPI_AFFILIATE_UPDATE_REQUESTER_INTERVAL}'
HAPI_HYPERION_API: '${HAPI_HYPERION_API}'
HAPI_HYPERION_START_AT: '${HAPI_HYPERION_START_AT}'
HAPI_EXCHANGE_API: '${HAPI_EXCHANGE_API}'
Expand Down
Binary file added docs/img/tech-stack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion hapi/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 EOS Costa Rica
Copyright (c) 2022 Sistemas Edenia Internacional S.A.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 6 additions & 0 deletions hapi/src/config/affiliate.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ module.exports = {
),
setRateInterval: parseInt(
process.env.HAPI_AFFILIATE_SET_RATE_INTERVAL || 86400
),
updateKycInterval: parseInt(
process.env.HAPI_AFFILIATE_UPDATE_KYC_INTERVAL || 18000
),
updateRequesterInterval: parseInt(
process.env.HAPI_AFFILIATE_UPDATE_REQUESTER_INTERVAL || 86400
)
}
2 changes: 1 addition & 1 deletion hapi/src/routes/add-join-request.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
to: input.email,
subject:
'Further action is required to activate your Proton Affiliate account',
template: mailTemplate.generateRejectionByKYC
template: mailTemplate.generateWarningByKYC
})
}

Expand Down
2 changes: 2 additions & 0 deletions hapi/src/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const addJoinRequest = require('./add-join-request.route')
const addReferralRoute = require('./add-referral.route')
const sendConfirmationRoute = require('./send-confirmation.route')
const rejectJoinRequestRoute = require('./reject-join-request.route')
const healthzRoute = require('./healthz.route')

module.exports = [
addJoinRequest,
addReferralRoute,
sendConfirmationRoute,
rejectJoinRequestRoute,
healthzRoute
]
50 changes: 50 additions & 0 deletions hapi/src/routes/reject-join-request.route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const Joi = require('joi')
const Boom = require('@hapi/boom')

const { joinRequestService, affiliateService } = require('../services')
const { mailUtil } = require('../utils')
const { mailTemplate } = require('../utils/templates')

module.exports = {
method: 'POST',
path: '/reject-join-request',
handler: async ({ payload: { input } }) => {
try {
for (const account of input.accounts) {
const joinRequest = await joinRequestService.findByAccount(account)
const hasKYC = await affiliateService.checkKyc(input.account)

if (hasKYC || !joinRequest) continue

try {
mailUtil.send({
account: account,
to: joinRequest.email,
subject:
'Further action is required to activate your Proton Affiliate account',
template: mailTemplate.generateRejectionByKYC
})
} catch (err) {
console.log(err)
}
}

const transaction = await joinRequestService.removeJoinRequest(
input.accounts
)

return { success: transaction.affected_rows > 0 }
} catch (error) {
throw Boom.badRequest(error.message, { code: 'BAD_REQUEST' })
}
},
options: {
validate: {
payload: Joi.object({
input: Joi.object({
accounts: Joi.array().items(Joi.string()).required()
}).required()
}).options({ stripUnknown: true })
}
}
}
Loading

0 comments on commit e14f4b7

Please sign in to comment.