diff --git a/src/config/development.js b/src/config/development.js new file mode 100644 index 00000000..8bb33afc --- /dev/null +++ b/src/config/development.js @@ -0,0 +1,8 @@ +// @flow +import { TX_SERVICE_HOST } from '~/config/names' + +const devConfig = { + [TX_SERVICE_HOST]: 'https://safe-transaction-history.dev.gnosisdev.com/api/v1/', +} + +export default devConfig diff --git a/src/config/index.js b/src/config/index.js new file mode 100644 index 00000000..66afd2c3 --- /dev/null +++ b/src/config/index.js @@ -0,0 +1,28 @@ +// @flow +import { ensureOnce } from '~/utils/singleton' +import { TX_SERVICE_HOST } from '~/config/names' +import devConfig from './development' +import testConfig from './testing' +import prodConfig from './production' + +const configuration = () => { + if (process.env.NODE_ENV === 'test') { + return testConfig + } + + if (process.env.NODE_ENV === 'production') { + return prodConfig + } + + return devConfig +} + +const getConfig = ensureOnce(configuration) + +export const getTxServiceHost = () => { + const config = getConfig() + + return config[TX_SERVICE_HOST] +} + +export const getTxServiceUriFrom = (safeAddress: string) => `safes/${safeAddress}/transactions/` diff --git a/src/config/names.js b/src/config/names.js new file mode 100644 index 00000000..5e00aa0d --- /dev/null +++ b/src/config/names.js @@ -0,0 +1,3 @@ +// @flow + +export const TX_SERVICE_HOST = 'tsh' diff --git a/src/config/production.js b/src/config/production.js new file mode 100644 index 00000000..7fcb5556 --- /dev/null +++ b/src/config/production.js @@ -0,0 +1,8 @@ +// @flow +import { TX_SERVICE_HOST } from '~/config/names' + +const prodConfig = { + [TX_SERVICE_HOST]: 'https://safe-transaction-history.dev.gnosisdev.com/api/v1/', +} + +export default prodConfig diff --git a/src/config/testing.js b/src/config/testing.js new file mode 100644 index 00000000..7f63e89a --- /dev/null +++ b/src/config/testing.js @@ -0,0 +1,8 @@ +// @flow +import { TX_SERVICE_HOST } from '~/config/names' + +const testConfig = { + [TX_SERVICE_HOST]: 'http://localhost:8080/api/v1/', +} + +export default testConfig