Skip to content

Commit

Permalink
Merge pull request #183 from EdgeApp/paul/multiPartnerId
Browse files Browse the repository at this point in the history
Paul/multi partner
  • Loading branch information
paullinator authored Feb 10, 2024
2 parents 9790009 + d5bec01 commit 2ea8e41
Show file tree
Hide file tree
Showing 49 changed files with 2,061 additions and 1,430 deletions.
21 changes: 19 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
{
"extends": [
"standard-kit/prettier",
"standard-kit/prettier/node",
"standard-kit/prettier/jsx",
"standard-kit/prettier/node",
"standard-kit/prettier/react",
"standard-kit/prettier/typescript"
],
"globals": {
"fetch": true
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-throw-literal": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/switch-exhaustiveness-check": "error"
}
}
],
"parserOptions": {
"project": "tsconfig.json"
},
"plugins": ["simple-import-sort"],
"rules": {
"simple-import-sort/sort": "error"
"simple-import-sort/imports": "error"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/cache/
/dist/
/lib/
/clientConfig.json
/config.json
/twitterex.txt

Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"args":[
"-r",
"sucrase/register",
"${workspaceFolder}/src/indexCache.js",
"${workspaceFolder}/src/indexCache.ts",
],
"skipFiles": [
"<node_internals>/**"
Expand Down
8 changes: 0 additions & 8 deletions config.sample.json

This file was deleted.

28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"fix": "npm run lint -- --fix",
"fio:promo": "node -r sucrase/register src/bin/fioPromo/fioPromo.ts",
"precommit": "lint-staged && npm run prepare",
"prepare": "npm-run-all clean -p build.*",
"prepare": "./scripts/prepare.sh && npm-run-all clean -p build.*",
"start": "node -r sucrase/register src/indexQuery.ts",
"start:cache": "node -r sucrase/register src/indexCache.ts",
"start:rates": "node -r sucrase/register src/indexRates.ts",
Expand All @@ -41,6 +41,7 @@
"axios": "^0.21.2",
"biggystring": "^3.0.2",
"body-parser": "^1.19.0",
"cleaner-config": "^0.1.10",
"cleaners": "^0.3.13",
"commander": "^6.1.0",
"cors": "^2.8.5",
Expand All @@ -66,20 +67,21 @@
"@types/node-fetch": "^2.6.3",
"@types/react": "^16.9.22",
"@types/react-dom": "^16.9.5",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"chai": "^4.3.4",
"eslint": ">=6.2.2",
"eslint-config-standard-kit": ">=0.14.4",
"eslint-plugin-import": ">=2.18.0",
"eslint-plugin-node": ">=9.1.0",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-promise": ">=4.2.1",
"eslint-plugin-react": ">=7.14.2",
"eslint-plugin-simple-import-sort": ">=4.0.0",
"eslint-plugin-standard": ">=4.0.0",
"eslint": "^8.19.0",
"eslint-config-standard-kit": "0.15.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^6.0.1",
"events": "^3.3.0",
"https-browserify": "^1.0.0",
"husky": ">=3.0.0",
Expand All @@ -94,7 +96,7 @@
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"sucrase": "^3.20.0",
"typescript": "^3.8.2",
"typescript": "^4.8.4",
"url": "^0.11.0",
"util": "^0.12.4"
}
Expand Down
11 changes: 11 additions & 0 deletions scripts/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# The Edge application uses WebView components extensively.
# These components need various JS files to operate,
# so this script prepares those.

set -e
cd "$(dirname "$0")/.."

# Assemble the clientConfig.json config file:
node -r sucrase/register ./src/bin/configure.ts
18 changes: 9 additions & 9 deletions src/apiAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface AnalyticsResult {
numAllTxs: number
}
appId: string
pluginId: string
partnerId: string
start: number
end: number
}
Expand All @@ -40,7 +40,7 @@ export const getAnalytics = (
start: number,
end: number,
appId: string,
pluginId: string,
partnerId: string,
timePeriod: string
): AnalyticsResult => {
// the creation of buckets
Expand All @@ -51,7 +51,7 @@ export const getAnalytics = (
const dayArray: Bucket[] = []
const hourArray: Bucket[] = []
// monthly buckets creation
if (hasMonthBucket === true) {
if (hasMonthBucket) {
let { y, m } = utcVariables(start)
let monthStart = new Date(Date.UTC(y, m, 1, 0))
do {
Expand All @@ -68,7 +68,7 @@ export const getAnalytics = (
} while (monthStart.getTime() <= end * 1000)
}
// daily buckets Creation
if (hasDayBucket === true) {
if (hasDayBucket) {
let { y, m, d } = utcVariables(start)
let dayStart = new Date(Date.UTC(y, m, d, 0))
do {
Expand All @@ -85,7 +85,7 @@ export const getAnalytics = (
} while (dayStart.getTime() <= end * 1000)
}
// hourly buckets creation
if (hasHourBucket === true) {
if (hasHourBucket) {
let { y, m, d, h } = utcVariables(start)
let hourStart = new Date(Date.UTC(y, m, d, h))
do {
Expand All @@ -108,19 +108,19 @@ export const getAnalytics = (
let hourPointer = 0
for (const tx of txs) {
// month
if (hasMonthBucket === true) {
if (hasMonthBucket) {
// advances pointer to bucket that matches current txs timestamp
monthPointer = bucketScroller(monthArray, monthPointer, tx.timestamp)
// adds usdvalue, currencycode, and currencypair to that bucket
bucketAdder(monthArray[monthPointer], tx)
}
// day
if (hasDayBucket === true) {
if (hasDayBucket) {
dayPointer = bucketScroller(dayArray, dayPointer, tx.timestamp)
bucketAdder(dayArray[dayPointer], tx)
}
// hour
if (hasHourBucket === true) {
if (hasHourBucket) {
hourPointer = bucketScroller(hourArray, hourPointer, tx.timestamp)
bucketAdder(hourArray[hourPointer], tx)
}
Expand All @@ -134,7 +134,7 @@ export const getAnalytics = (
numAllTxs: txs.length
},
appId,
pluginId,
partnerId,
start: start,
end: end
}
Expand Down
13 changes: 6 additions & 7 deletions src/bin/bogReporter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import fetch from 'node-fetch'

import CONFIG from '../../config.json'
import { config } from '../config'

// @ts-ignore
const BITS_OF_GOLD_API_KEY = CONFIG.bog.apiKey
const BITS_OF_GOLD_API_KEY = config.bog.apiKey

const dateRegex = RegExp(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/)
const dateRegex = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/

async function queryBog(): Promise<void> {
// Grab args and verify format
Expand Down Expand Up @@ -53,7 +52,7 @@ async function queryBog(): Promise<void> {
)
}
} catch (e) {
console.log(e.message)
console.log(String(e))
}
}
// Print totals
Expand All @@ -71,7 +70,7 @@ async function queryFiatRate(
method: 'GET'
}
)
if (result.ok !== true) {
if (!result.ok) {
throw new Error(`queryFiatRate failed with status code ${result.status}`)
}
const json = await result.json()
Expand All @@ -88,7 +87,7 @@ async function queryCryptoRate(
method: 'GET'
}
)
if (result.ok !== true) {
if (!result.ok) {
throw new Error(`queryCryptoRate failed with status code ${result.status}`)
}
const json = await result.json()
Expand Down
5 changes: 5 additions & 0 deletions src/bin/configure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { makeConfig } from 'cleaner-config'

import { asClientConfig } from '../demo/clientConfig'

export const clientConfig = makeConfig(asClientConfig, './clientConfig.json')
5 changes: 2 additions & 3 deletions src/bin/fioPromo/fioLookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const {
} = defaultSettings

const configFile: string = fs.readFileSync(
`${__dirname}/../../../config.json`,
path.join(__dirname, `/../../../config.json`),
'utf8'
)
const config = JSON.parse(configFile)
Expand Down Expand Up @@ -94,8 +94,7 @@ export const checkAddress = async (
error = ''
break
} catch (e) {
error = e
console.log(e)
console.log(String(e))
}
}
if (error !== '') throw error
Expand Down
Loading

0 comments on commit 2ea8e41

Please sign in to comment.