Skip to content

Commit

Permalink
Merge branch 'master' into aaronmgdr/thesplintering
Browse files Browse the repository at this point in the history
* master:
  [Wallet] Use Charles proxy to see eth JSON rpc calls when using forno (#2204)
  [Wallet] Disable skip button when the user enable contact access (#2224)
  [Wallet] Redesigning notification lists (#1967)
  [Wallet] Fix crash on iOS when segment is enabled (#2222)
  Update documentation wrt. epoch rewards fractions (#2182)
  Improvement facilitating to run a full node (#2130)
  [BlockchainApi] Add ability to get exchange rates from/to cGLD or cUSD (#2005)
  Improve reliability of e2e governance test (#2208)
  Fix/protocol test flakyness (#2155)
  Fix bignumber display in CLI (#2212)
  Doc changes to address frequently asked questions (#2209)
  Upgrade TS version (#2196)
  Wait for only waitTime - 1 blocks (#2207)
  Minor baklava docs reconnection fixes (#2215)
  Update walletkit gateway fee to fix transactions in forno mode (#2211)
  Update baklava network ID in docs for 1.1 (#2214)
  Support more than 1 attesation bot at a time (#2192)
  Check sync status of attestation service (#2191)
  Indicate to run Twilio globally (#2193)
  Add Twilio and attestation bot envs (#2194)
  • Loading branch information
aaronmgdr committed Dec 12, 2019
2 parents 703405b + 4aafcf9 commit f4f4036
Show file tree
Hide file tree
Showing 183 changed files with 5,802 additions and 5,206 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ GETH_BOOTNODE_DOCKER_IMAGE_REPOSITORY="us.gcr.io/celo-testnet/geth-all"
GETH_BOOTNODE_DOCKER_IMAGE_TAG="master"

CELOTOOL_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/celo-monorepo"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-6d4579212a7b49fdf54e2f4661c40ae8f4fbc4c5"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-53016a800a510cddae73444377bcf366d753367a"

CELOCLI_STANDALONE_IMAGE_REPOSITORY="gcr.io/celo-testnet/celocli-standalone"
CELOCLI_STANDALONE_IMAGE_TAG="0.0.30-beta2"
Expand Down
7 changes: 6 additions & 1 deletion .env.baklava
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ GETH_BOOTNODE_DOCKER_IMAGE_REPOSITORY="us.gcr.io/celo-testnet/geth-all"
GETH_BOOTNODE_DOCKER_IMAGE_TAG="6e3766093331ef1cef8428c2320c60f62390adeb"

CELOTOOL_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/celo-monorepo"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-dcad01808c05f77ea71b911ba331caab0fd739d3"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-53016a800a510cddae73444377bcf366d753367a"

CELOCLI_STANDALONE_IMAGE_REPOSITORY="gcr.io/celo-testnet/celocli-standalone"
CELOCLI_STANDALONE_IMAGE_TAG="0.0.30-beta2"
Expand Down Expand Up @@ -109,3 +109,8 @@ PROMTOSD_SCRAPE_INTERVAL="5m"
PROMTOSD_EXPORT_INTERVAL="5m"

SMS_RETRIEVER_HASH_CODE=l5k6LvdPDXS

# Attestation Bot variables
ATTESTATION_BOT_INITIAL_WAIT_SECONDS=3
ATTESTATION_BOT_IN_BETWEEN_WAIT_SECONDS=10
ATTESTATION_BOT_MAX_ATTESTATIONS=3
7 changes: 6 additions & 1 deletion .env.baklavastaging
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ GETH_BOOTNODE_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/geth-all"
GETH_BOOTNODE_DOCKER_IMAGE_TAG="a85db20179b503b802430aef7085d35aa761c63d"

CELOTOOL_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/celo-monorepo"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-51ae8e72be34a614346950b6fbd8ba3b94223947"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-53016a800a510cddae73444377bcf366d753367a"

CELOCLI_STANDALONE_IMAGE_REPOSITORY="gcr.io/celo-testnet/celocli-standalone"
CELOCLI_STANDALONE_IMAGE_TAG="0.0.30-beta2"
Expand Down Expand Up @@ -108,3 +108,8 @@ PROMTOSD_SCRAPE_INTERVAL="5m"
PROMTOSD_EXPORT_INTERVAL="5m"

SMS_RETRIEVER_HASH_CODE=l5k6LvdPDXS

# Attestation Bot variables
ATTESTATION_BOT_INITIAL_WAIT_SECONDS=3
ATTESTATION_BOT_IN_BETWEEN_WAIT_SECONDS=10
ATTESTATION_BOT_MAX_ATTESTATIONS=3
2 changes: 1 addition & 1 deletion .env.integration
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ GETH_BOOTNODE_DOCKER_IMAGE_REPOSITORY="us.gcr.io/celo-testnet/geth-all"
GETH_BOOTNODE_DOCKER_IMAGE_TAG="803c05715bd12a3c148fa870e208cbdcebcc8cb8"

CELOTOOL_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/celo-monorepo"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-5bea6d30cbe6aa4272b32a4d2cfed5567f422ea9"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-53016a800a510cddae73444377bcf366d753367a"

CELOCLI_STANDALONE_IMAGE_REPOSITORY="gcr.io/celo-testnet/celocli-standalone"
CELOCLI_STANDALONE_IMAGE_TAG="0.0.30-beta2"
Expand Down
Binary file modified .env.mnemonic.baklava.enc
Binary file not shown.
Binary file modified .env.mnemonic.baklavastaging.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ packages/protocol/types/
!packages/protocol/lib/**/*.ts
packages/protocol/scripts/**/*.js
packages/protocol/migrations/**/*.js
packages/protocol/tests/**/*.js
packages/protocol/test/**/*.js

packages/verification-pool-api/contracts/*.ts

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"ts-node": "^8.3.0",
"tsconfig-paths": "^3.8.0",
"tslint": "^5.20.0",
"typescript": "^3.5.3",
"typescript": "^3.7.3",
"typescript-tslint-plugin": "^0.5.4"
},
"dependencies": {
Expand Down
29 changes: 25 additions & 4 deletions packages/attestation-service/src/db.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ContractKit, newKit } from '@celo/contractkit'
import { FindOptions, Sequelize } from 'sequelize'
import { Block } from 'web3/eth/types'
import { fetchEnv } from './env'
import { rootLogger } from './logger'
import Attestation, { AttestationModel, AttestationStatic } from './models/attestation'
Expand All @@ -22,11 +23,31 @@ export let kit: ContractKit
export async function initializeKit() {
if (kit === undefined) {
kit = newKit(fetchEnv('CELO_PROVIDER'))
const blockNumber = await kit.web3.eth.getBlockNumber()
if (blockNumber === 0) {
throw new Error(
'Could not fetch latest block from web3 provider ' + fetchEnv('CELO_PROVIDER')
// Copied from @celo/cli/src/utils/helpers
try {
const syncProgress = await kit.web3.eth.isSyncing()
if (typeof syncProgress === 'boolean' && !syncProgress) {
const latestBlock: Block = await kit.web3.eth.getBlock('latest')
if (latestBlock && latestBlock.number > 0) {
// To catch the case in which syncing has happened in the past,
// has stopped, and hasn't started again, check for an old timestamp
// on the latest block
const ageOfBlock = Date.now() / 1000 - latestBlock.timestamp
if (ageOfBlock > 120) {
throw new Error(
`Latest block is ${ageOfBlock} seconds old, and syncing is not currently in progress`
)
}
}
} else {
throw new Error('Node is not syncing')
}
} catch (error) {
rootLogger.error(
'Initializing Kit failed, are you running your node and specified it with the "CELO_PROVIDER" env var?. It\' currently set as ' +
fetchEnv('CELO_PROVIDER')
)
throw error
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/attestation-service/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { createStream } from 'bunyan-gke-stackdriver'
import { fetchEnvOrDefault } from './env'

const logLevel = fetchEnvOrDefault('LOG_LEVEL', 'info') as LogLevelString
const logFormat = fetchEnvOrDefault('LOG_FORMAT', 'json')
const logFormat = fetchEnvOrDefault('LOG_FORMAT', 'human')

let stream: any
switch (logFormat) {
case 'stackdriver':
stream = createStream(levelFromName[logLevel])
break
case 'human':
stream = { level: logLevel, stream: bunyanDebugStream() }
case 'json':
stream = { stream: process.stdout, level: logLevel }
break
default:
stream = { stream: process.stdout, level: logLevel }
stream = { level: logLevel, stream: bunyanDebugStream() }
break
}

Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-api/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DEPLOY_ENV=local
EXCHANGE_RATES_API=https://apilayer.net/api
BLOCKSCOUT_API=https://integration-blockscout.celo-testnet.org/api
FIREBASE_DB=https://celo-org-mobile-int.firebaseio.com
FAUCET_ADDRESS=0x47e172F6CfB6c7D01C1574fa3E2Be7CC73269D95
VERIFICATION_REWARDS_ADDRESS=0xb4fdaf5f3cd313654aa357299ada901b1d2dd3b5
WEB3_PROVIDER_URL=https://integration-forno.celo-testnet.org
3 changes: 3 additions & 0 deletions packages/blockchain-api/.gcloudignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ dist/
# Exclude dependencies
node_modules/
.env

# Exclude tests
*.test.ts
3 changes: 2 additions & 1 deletion packages/blockchain-api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ dist/
# Exclude dependencies
node_modules/

# keys
# Exclude secrets
serviceAccountKey.json
src/secrets.json
2 changes: 2 additions & 0 deletions packages/blockchain-api/__mocks__/@celo/contractkit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Empty implementation because it currently adds ~8 secs for each test
// TODO: investigate why
2 changes: 2 additions & 0 deletions packages/blockchain-api/__mocks__/firebase-admin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const initializeApp = jest.fn()
export const database = jest.fn()
1 change: 1 addition & 0 deletions packages/blockchain-api/app.alfajores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env_variables:
DEPLOY_ENV: "alfajores"
EXCHANGE_RATES_API: "https://apilayer.net/api"
BLOCKSCOUT_API: "https://alfajores-blockscout.celo-testnet.org/api"
FIREBASE_DB: "https://celo-org-mobile-alfajores.firebaseio.com"
# TODO Pull addresses from the build artifacts of the network in protocol/build
FAUCET_ADDRESS: "0xCEa3eF8e187490A9d85A1849D98412E5D27D1Bb3"
VERIFICATION_REWARDS_ADDRESS: "0xb4fdaf5f3cd313654aa357299ada901b1d2dd3b5"
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-api/app.alfajoresstaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env_variables:
DEPLOY_ENV: "alfajoresstaging"
EXCHANGE_RATES_API: "https://apilayer.net/api"
BLOCKSCOUT_API: "https://alfajoresstaging-blockscout.celo-testnet.org/api"
FIREBASE_DB: "https://celo-org-mobile-alfajoresstaging.firebaseio.com"
# TODO Pull addresses from the build artifacts of the network in protocol/build
FAUCET_ADDRESS: "0xF4314cb9046bECe6AA54bb9533155434d0c76909"
VERIFICATION_REWARDS_ADDRESS: "0xb4fdaf5f3cd313654aa357299ada901b1d2dd3b5"
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-api/app.integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env_variables:
DEPLOY_ENV: "integration"
EXCHANGE_RATES_API: "https://apilayer.net/api"
BLOCKSCOUT_API: "https://integration-blockscout.celo-testnet.org/api"
FIREBASE_DB: "https://celo-org-mobile-int.firebaseio.com"
# TODO Pull addresses from the build artifacts of the network in protocol/build
FAUCET_ADDRESS: "0x47e172F6CfB6c7D01C1574fa3E2Be7CC73269D95"
VERIFICATION_REWARDS_ADDRESS: "0xb4fdaf5f3cd313654aa357299ada901b1d2dd3b5"
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-api/app.pilot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env_variables:
DEPLOY_ENV: "pilot"
EXCHANGE_RATES_API: "https://apilayer.net/api"
BLOCKSCOUT_API: "https://pilot-blockscout.celo-testnet.org/api"
FIREBASE_DB: "https://celo-org-mobile-pilot.firebaseio.com"
# TODO Pull addresses from the build artifacts of the network in protocol/build
FAUCET_ADDRESS: "0x387bCb16Bfcd37AccEcF5c9eB2938E30d3aB8BF2"
VERIFICATION_REWARDS_ADDRESS: "0xb4fdaf5f3cd313654aa357299ada901b1d2dd3b5"
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-api/app.pilotstaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env_variables:
DEPLOY_ENV: "pilotstaging"
EXCHANGE_RATES_API: "https://apilayer.net/api"
BLOCKSCOUT_API: "https://pilotstaging-blockscout.celo-testnet.org/api"
FIREBASE_DB: "https://celo-org-mobile-pilotstaging.firebaseio.com"
# TODO Pull addresses from the build artifacts of the network in protocol/build
FAUCET_ADDRESS: "0x545DEBe3030B570731EDab192640804AC8Cf65CA"
VERIFICATION_REWARDS_ADDRESS: "0xb4fdaf5f3cd313654aa357299ada901b1d2dd3b5"
Expand Down
3 changes: 2 additions & 1 deletion packages/blockchain-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"bignumber.js": "^7.2.0",
"dotenv": "^6.1.0",
"express": "^4.16.4",
"firebase-admin": "^8.6.1",
"graphql": "^14.1.1",
"utf8": "^3.0.0",
"web3-eth-abi": "1.0.0-beta.37"
Expand All @@ -35,7 +36,7 @@
"@types/web3": "^1.0.18",
"jest-fetch-mock": "^2.1.2",
"tsc-watch": "^1.0.31",
"typescript": "^3.5.3"
"typescript": "^3.7.3"
},
"resolutions": {
"**/cross-fetch": "3.0.4"
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/blockchain-api/src/apolloServer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloServer } from 'apollo-server-express'
import { BlockscoutAPI } from './blockscout'
import { CurrencyConversionAPI } from './currencyConversion'
import CurrencyConversionAPI from './currencyConversion/CurrencyConversionAPI'
import { resolvers, typeDefs } from './schema'

export interface DataSources {
Expand Down
24 changes: 24 additions & 0 deletions packages/blockchain-api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,34 @@ function getSecrets(deployEnv: string) {
return envSecrets
}

export function getFirebaseAdminCreds(admin: any) {
// TODO: move project to celo-org-mobile
// until then, using serviceAccountKey for all envs
// tslint:disable-next-line: no-constant-condition
if (true /* DEPLOY_ENV === 'local' */) {
try {
const serviceAccount = require('../serviceAccountKey.json')
return admin.credential.cert(serviceAccount)
} catch (error) {
console.error(
'Error: Could not initialize admin credentials. Is serviceAccountKey.json missing?',
error
)
}
} else {
try {
return admin.credential.applicationDefault()
} catch (error) {
console.error('Error: Could not retrieve default app creds', error)
}
}
}

export const DEPLOY_ENV = (process.env.DEPLOY_ENV as string).toLowerCase()
export const EXCHANGE_RATES_API = (process.env.EXCHANGE_RATES_API as string).toLowerCase()
export const { EXCHANGE_RATES_API_ACCESS_KEY } = getSecrets(DEPLOY_ENV)
export const BLOCKSCOUT_API = (process.env.BLOCKSCOUT_API as string).toLowerCase()
export const FIREBASE_DB = process.env.FIREBASE_DB
export const FAUCET_ADDRESS = (process.env.FAUCET_ADDRESS as string).toLowerCase()
export const VERIFICATION_REWARDS_ADDRESS = (process.env
.VERIFICATION_REWARDS_ADDRESS as string).toLowerCase()
Expand Down
Loading

0 comments on commit f4f4036

Please sign in to comment.