Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Estimator url prod/dev #1183

Merged
merged 9 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ before_install:
# Needed to deploy pull request and releases
- sudo apt-get -y install python-pip python-dev
- pip install awscli --upgrade --user
# use production url for price estimator on master or tagged
- export PRICE_ESTIMATOR_URL=$([[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fancy! I was thinking something way simpler, but hey, glad you are doing this :)

$TRAVIS_BRANCH = master || \
$TRAVIS_BRANCH = release/* || \
$TRAVIS_BRANCH = hotfix/* || \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I guess to make sure it works, we need to merge the thing :)

We now have an open hotfix, it's a great moment to get this thing merged 👍

$TRAVIS_TAG != "" ]] && \
echo "production" || echo "develop")
before_deploy:
# zip ./dist folder if tag IS present
- if [[ $TRAVIS_TAG != "" && $IPFS_HASH = "" ]]; then
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,16 @@ dexPriceEstimator:
type: 'dex-price-estimator'
config:
- networkId: number
url: string
url_production: string
url_develop: string
```

Where:

- `type` can only be `dex-price-estimator`.
- `networkId` is a number, such as `1` for Mainnet, `4` for Rinkeby and so on.
- `url` the endpoint for given `networkId`
- `url_production` the endpoint for given `networkId` to use in production
- `url_develop` the endpoint for given `networkId` to use in development (optional)

### `theGraphApi`

Expand Down
6 changes: 4 additions & 2 deletions config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ dexPriceEstimator:
type: 'dex-price-estimator' # choices: dex-price-estimator
config:
- networkId: 1
url: https://dex-price-estimator.gnosis.io
url_production: https://dex-price-estimator.gnosis.io
url_develop: https://price-estimate-mainnet.dev.gnosisdev.com

- networkId: 4
url: https://dex-price-estimator.rinkeby.gnosis.io
url_production: https://dex-price-estimator.rinkeby.gnosis.io
url_develop: https://price-estimate-rinkeby.dev.gnosisdev.com

# Subgraph abstraction, used for getting the last price
theGraphApi:
Expand Down
9 changes: 7 additions & 2 deletions src/api/dexPriceEstimator/DexPriceEstimatorApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ interface GetPriceResponse {

export interface PriceEstimatorEndpoint {
networkId: number
url: string
url_production: string
url_develop?: string
}

export type DexPriceEstimatorParams = PriceEstimatorEndpoint[]
Expand All @@ -57,7 +58,11 @@ export class DexPriceEstimatorApiImpl implements DexPriceEstimatorApi {

public constructor(params: DexPriceEstimatorParams) {
params.forEach(endpoint => {
this.urlsByNetwork[endpoint.networkId] = getDexPriceEstimatorUrl(endpoint.url)
this.urlsByNetwork[endpoint.networkId] = getDexPriceEstimatorUrl(
process.env.PRICE_ESTIMATOR_URL === 'production'
? endpoint.url_production
: endpoint.url_develop || endpoint.url_production, // fallback on required url_production
)
})
}

Expand Down
6 changes: 4 additions & 2 deletions test/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ describe('Test config defaults', () => {
config: [
{
networkId: 1,
url: 'https://dex-price-estimator.gnosis.io',
url_production: 'https://dex-price-estimator.gnosis.io',
url_develop: 'https://price-estimate-mainnet.dev.gnosisdev.com',
},
{
networkId: 4,
url: 'https://dex-price-estimator.rinkeby.gnosis.io',
url_production: 'https://dex-price-estimator.rinkeby.gnosis.io',
url_develop: 'https://price-estimate-rinkeby.dev.gnosisdev.com',
},
],
}
Expand Down
1 change: 1 addition & 0 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module.exports = ({ stats = false } = {}) => ({
MOCK_WEB3: process.env.MOCK || 'false',
// AUTOCONNECT: only applies for mock implementation
AUTOCONNECT: 'true',
PRICE_ESTIMATOR_URL: process.env.PRICE_ESTIMATOR_URL || 'develop',
}),
new ForkTsCheckerWebpackPlugin({ silent: stats }),
// define inside one plugin instance
Expand Down