Skip to content

Commit

Permalink
Merge branch 'master' into aaronmgdr/static
Browse files Browse the repository at this point in the history
* master:
  Adding a command to the docker script allowing to stop validating (#2295)
  Update prettier to 1.19.1 to support TypeScript 3.7 (optional chaining, nullish coalescing, etc) (#2358)
  Fixes needed to make slashing work (#2346)
  Remove Rewards page from web (#2353)
  Remove rep sentence from brand kit page (#2350)

# Conflicts:
#	packages/web/src/header/Header.3.tsx
#	yarn.lock
  • Loading branch information
aaronmgdr committed Jan 3, 2020
2 parents aa2fde6 + e9690e3 commit a90d747
Show file tree
Hide file tree
Showing 117 changed files with 836 additions and 950 deletions.
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"jest-snapshot": "^24.9.0",
"lerna": "^3.16.0",
"patch-package": "^5.1.1",
"prettier": "1.13.5",
"prettier-plugin-java": "^0.4.0",
"prettier-plugin-solidity": "1.0.0-alpha.34",
"pretty-quick": "^1.11.1",
"prettier": "1.19.1",
"prettier-plugin-java": "^0.6.0",
"prettier-plugin-solidity": "1.0.0-alpha.35",
"pretty-quick": "^2.0.1",
"solc": "0.5.8",
"ts-jest": "^24.1.0",
"ts-node": "^8.3.0",
Expand All @@ -74,6 +74,8 @@
"**/extend": "^3.0.2",
"**/cross-fetch": "^3.0.2",
"sha3": "1.2.3",
"bignumber.js": "9.0.0"
"bignumber.js": "9.0.0",
"prettier": "^1.19.1",
"@types/prettier": "^1.19.0"
}
}
4 changes: 1 addition & 3 deletions packages/attestation-service/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ function serializeErrors(errors: t.Errors) {
const path = error.context.map(({ key }) => key).join('.')
const value =
error.message ||
`Expected value at path ${path} to be of type ${expectedType.name}, but received ${
error.value
}`
`Expected value at path ${path} to be of type ${expectedType.name}, but received ${error.value}`

// Create recursive payload in case of nested properties
let payload: any = value
Expand Down
8 changes: 2 additions & 6 deletions packages/blockchain-api/src/blockscout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ export class BlockscoutAPI extends RESTDataSource {
})

console.info(
`[Celo] getFeedEvents address=${args.address} startblock=${args.startblock} endblock=${
args.endblock
} rawTransactionCount=${rawTransactions.length} eventCount=${events.length}`
`[Celo] getFeedEvents address=${args.address} startblock=${args.startblock} endblock=${args.endblock} rawTransactionCount=${rawTransactions.length} eventCount=${events.length}`
)
return events.sort((a, b) => b.timestamp - a.timestamp)
}
Expand All @@ -212,9 +210,7 @@ export class BlockscoutAPI extends RESTDataSource {
})
}
console.info(
`[Celo] getFeedRewards address=${args.address} startblock=${args.startblock} endblock=${
args.endblock
} rawTransactionCount=${rawTransactions.length} rewardsCount=${rewards.length}`
`[Celo] getFeedRewards address=${args.address} startblock=${args.startblock} endblock=${args.endblock} rawTransactionCount=${rawTransactions.length} rewardsCount=${rewards.length}`
)
return rewards.sort((a, b) => b.timestamp - a.timestamp)
}
Expand Down
4 changes: 1 addition & 3 deletions packages/celotool/src/cmds/account/faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ export const handler = async (argv: FaucetArgv) => {
(argv.dollar !== 0 && !(await stableToken.balanceOf(address)).isZero())
) {
console.error(
`Unable to faucet ${address} on ${
argv.celoEnv
}: --checkzero specified, but balance is non-zero`
`Unable to faucet ${address} on ${argv.celoEnv}: --checkzero specified, but balance is non-zero`
)
process.exit(1)
}
Expand Down
4 changes: 1 addition & 3 deletions packages/celotool/src/cmds/account/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export const handler = async (argv: LookupArgv) => {
Object.keys(matchingAddresses).map((address) => {
const attestationsStats = matchingAddresses[address]
console.info(
`${address} is attested to ${argv.phone} with ${
attestationsStats.completed
} completed attestations out of ${attestationsStats.total} total`
`${address} is attested to ${argv.phone} with ${attestationsStats.completed} completed attestations out of ${attestationsStats.total} total`
)
})
}
Expand Down
8 changes: 2 additions & 6 deletions packages/celotool/src/cmds/account/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ export async function printCurrentCompletedAttestations(
const attestationStat = await attestations.getAttestationStat(phoneNumber, account)

console.info(
`Phone Number: ${phoneNumber} has completed ${
attestationStat.completed
} attestations out of a total of ${attestationStat.total}`
`Phone Number: ${phoneNumber} has completed ${attestationStat.completed} attestations out of a total of ${attestationStat.total}`
)
}

Expand Down Expand Up @@ -166,9 +164,7 @@ async function promptForCodeAndVerify(
const userResponse = await prompts({
type: 'text',
name: 'code',
message: `${
attestationsToComplete.length
} attestations completable. Enter the code here or type exit`,
message: `${attestationsToComplete.length} attestations completable. Enter the code here or type exit`,
})

if (userResponse.code === 'exit') {
Expand Down
4 changes: 1 addition & 3 deletions packages/celotool/src/cmds/deploy/initial/blockchain-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export const handler = async (argv: BlockchainApiArgv) => {
const newFaucetAddress = getAddressFromEnv(AccountType.VALIDATOR, 0) // We use the 0th validator as the faucet
console.info(`updating blockchain-api yaml file for env ${argv.celoEnv}`)
await execCmd(
`sed -i.bak 's/FAUCET_ADDRESS: .*$/FAUCET_ADDRESS: \"${newFaucetAddress}\"/g' ../blockchain-api/app.${
argv.celoEnv
}.yaml`
`sed -i.bak 's/FAUCET_ADDRESS: .*$/FAUCET_ADDRESS: \"${newFaucetAddress}\"/g' ../blockchain-api/app.${argv.celoEnv}.yaml`
)
await execCmd(`rm ../blockchain-api/app.${argv.celoEnv}.yaml.bak`) // Removing temporary bak file
console.info(`deploying blockchain-api for env ${argv.config} to ${testnetProjectName}`)
Expand Down
8 changes: 2 additions & 6 deletions packages/celotool/src/cmds/deploy/upgrade/faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ export const handler = async (argv: UpgradeFaucetArgs) => {

console.info(`Updating contract addresses for ${argv.celoEnv} on ${argv.firebaseProject}`)
await execCmd(
`yarn --cwd ../faucet cli config:set --net ${argv.celoEnv} --escrowAddress ${
addressMap.escrow
} --goldTokenAddress ${addressMap.goldToken} --stableTokenAddress ${addressMap.stableToken}`
`yarn --cwd ../faucet cli config:set --net ${argv.celoEnv} --escrowAddress ${addressMap.escrow} --goldTokenAddress ${addressMap.goldToken} --stableTokenAddress ${addressMap.stableToken}`
)
console.info(`Redepolying functions (neeeded for config changes to take place)`)
await execCmd('yarn --cwd ../faucet cli deploy:functions')
Expand All @@ -92,9 +90,7 @@ export const handler = async (argv: UpgradeFaucetArgs) => {
await portForwardAnd(argv.celoEnv, fundFaucetAccounts)

console.info(
`Done updating contract addresses and funding the faucet account for network ${
argv.celoEnv
} in ${argv.firebaseProject}`
`Done updating contract addresses and funding the faucet account for network ${argv.celoEnv} in ${argv.firebaseProject}`
)
console.info('Please double check the TX node IP address to ensure it did not change.')
process.exit(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export const handler = async (argv: Argv) => {

try {
await execCmd(
`gcloud compute target-pools get-health ${target} --region=${zone} --format=json --project=${
argv.project
}`,
`gcloud compute target-pools get-health ${target} --region=${zone} --format=json --project=${argv.project}`,
{},
true
)
Expand Down
5 changes: 2 additions & 3 deletions packages/celotool/src/cmds/geth/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ export const builder = (argv: yargs.Argv) => {
description: 'Verbosity level',
default: 5,
})
.coerce(
'miner-address',
(minerAddress: string) => (minerAddress === null ? null : ensure0x(minerAddress))
.coerce('miner-address', (minerAddress: string) =>
minerAddress === null ? null : ensure0x(minerAddress)
)
}

Expand Down
4 changes: 1 addition & 3 deletions packages/celotool/src/cmds/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ export const handler = async (argv: RestoreArgv) => {
// That itself requires that the miner node be stopped.
// For now, this step is intentionally manual.
// When we encounter a real world use-case of restore, we can decide whether to automate this or not.
const restoreSnapshotCmd = `gcloud compute disks create ${pvcFullId} --source-snapshot=${
argv.snapshotname
} --type ${diskType}`
const restoreSnapshotCmd = `gcloud compute disks create ${pvcFullId} --source-snapshot=${argv.snapshotname} --type ${diskType}`
await execCmdWithExitOnFailure(restoreSnapshotCmd)
// const gcloudSnapshotsUrl = 'https://console.cloud.google.com/compute/snapshots'
// console.info(`Snapshot \"${snapshotName}\" can be seen at ${gcloudSnapshotsUrl}`)
Expand Down
7 changes: 3 additions & 4 deletions packages/celotool/src/e2e-tests/governance_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ async function newMemberSwapper(kit: ContractKit, members: string[]): Promise<Me
}

async function addMember(member: string) {
return (await (await kit.contracts.getValidators()).addMember(
group,
member
)).sendAndWaitForReceipt({ from: group })
return (
await (await kit.contracts.getValidators()).addMember(group, member)
).sendAndWaitForReceipt({ from: group })
}

async function getGroupMembers() {
Expand Down
6 changes: 3 additions & 3 deletions packages/celotool/src/lib/attestation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export async function removeHelmRelease(celoEnv: string) {
export async function upgradeHelmChart(celoEnv: string) {
console.info(`Upgrading helm release ${releaseName(celoEnv)}`)

const upgradeCmdArgs = `${releaseName(
celoEnv
)} ${helmChartPath} --namespace ${celoEnv} ${(await helmParameters(celoEnv)).join(' ')}`
const upgradeCmdArgs = `${releaseName(celoEnv)} ${helmChartPath} --namespace ${celoEnv} ${(
await helmParameters(celoEnv)
).join(' ')}`

if (process.env.CELOTOOL_VERBOSE === 'true') {
await execCmdWithExitOnFailure(`helm upgrade --debug --dry-run ${upgradeCmdArgs}`)
Expand Down
14 changes: 8 additions & 6 deletions packages/celotool/src/lib/blockscout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ export async function upgradeHelmChart(
blockscoutDBConnectionName: string
) {
console.info(`Upgrading helm release ${celoEnv}-blockscout`)
const params = (await helmParameters(
celoEnv,
blockscoutDBUsername,
blockscoutDBPassword,
blockscoutDBConnectionName
)).join(' ')
const params = (
await helmParameters(
celoEnv,
blockscoutDBUsername,
blockscoutDBPassword,
blockscoutDBConnectionName
)
).join(' ')
if (process.env.CELOTOOL_VERBOSE === 'true') {
await execCmdWithExitOnFailure(
`helm upgrade --debug --dry-run ${celoEnv}-blockscout ../helm-charts/blockscout --namespace ${celoEnv} ${params}`
Expand Down
4 changes: 1 addition & 3 deletions packages/celotool/src/lib/env-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ function celoEnvMiddleware(argv: CeloEnvArgv) {
export async function doCheckOrPromptIfStagingOrProduction() {
if (process.env.CELOTOOL_CONFIRMED !== 'true' && isProduction()) {
await confirmAction(
`You are about to apply a possibly irreversible action on a production env: ${
process.env.CELOTOOL_CELOENV
}. Are you sure?`
`You are about to apply a possibly irreversible action on a production env: ${process.env.CELOTOOL_CELOENV}. Are you sure?`
)
process.env.CELOTOOL_CONFIRMED = 'true'
}
Expand Down
8 changes: 5 additions & 3 deletions packages/celotool/src/lib/geth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ const getEnodesWithIpAddresses = async (namespace: string, getExternalIP: boolea
if (getExternalIP) {
address = txAddresses[index]
} else {
address = (await execCmd(
`kubectl get service/${namespace}-service-${index} --namespace ${namespace} -o jsonpath='{.spec.clusterIP}'`
))[0]
address = (
await execCmd(
`kubectl get service/${namespace}-service-${index} --namespace ${namespace} -o jsonpath='{.spec.clusterIP}'`
)
)[0]
if (address.length === 0) {
console.error('IP address is empty for transaction node')
throw new Error('IP address is empty for transaction node')
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@types/node": "^10",
"@types/web3": "^1.0.18",
"globby": "^8",
"prettier": "1.13.5",
"prettier": "1.19.1",
"typescript": "^3.7.3"
},
"files": [
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/utils/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ class CheckBuilder {
)

isValidator = (account: Address) =>
this.addCheck(`${account} is Validator`, this.withValidators((v) => v.isValidator(account)))
this.addCheck(
`${account} is Validator`,
this.withValidators((v) => v.isValidator(account))
)

isValidatorGroup = (account: Address) =>
this.addCheck(
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/utils/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export const displayMetadata = async (metadata: IdentityMetadataWrapper, kit: Co
const status = verifiable
? await verifyClaim(claim, metadata.data.meta.address, metadataURLGetter)
: validatable
? await validateClaim(claim, metadata.data.meta.address, kit)
: 'N/A'
? await validateClaim(claim, metadata.data.meta.address, kit)
: 'N/A'
let extra = ''
switch (claim.type) {
case ClaimTypes.ATTESTATION_SERVICE_URL:
Expand All @@ -123,10 +123,10 @@ export const displayMetadata = async (metadata: IdentityMetadataWrapper, kit: Co
? `Could not verify: ${status}`
: 'Verified!'
: validatable
? status
? `Invalid: ${status}`
: `Valid!`
: 'N/A',
? status
? `Invalid: ${status}`
: `Valid!`
: 'N/A',
createdAt: moment.unix(claim.timestamp).fromNow(),
}
})
Expand Down
12 changes: 6 additions & 6 deletions packages/contractkit/src/identity/claims/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export type Claim =
export type ClaimPayload<K extends ClaimTypes> = K extends typeof ClaimTypes.DOMAIN
? DomainClaim
: K extends typeof ClaimTypes.NAME
? NameClaim
: K extends typeof ClaimTypes.KEYBASE
? KeybaseClaim
: K extends typeof ClaimTypes.ATTESTATION_SERVICE_URL
? AttestationServiceURLClaim
: AccountClaim
? NameClaim
: K extends typeof ClaimTypes.KEYBASE
? KeybaseClaim
: K extends typeof ClaimTypes.ATTESTATION_SERVICE_URL
? AttestationServiceURLClaim
: AccountClaim

export const isOfType = <K extends ClaimTypes>(type: K) => (data: Claim): data is ClaimPayload<K> =>
data.type === type
Expand Down
4 changes: 1 addition & 3 deletions packages/contractkit/src/utils/tx-signing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ async function verifyLocalSigning(web3: Web3, celoTransaction: CeloTx): Promise<
if (celoTransaction.gatewayFeeRecipient != null) {
debug(
'Checking gateway fee recipient actual ' +
`${signedCeloTransaction.gatewayFeeRecipient} expected ${
celoTransaction.gatewayFeeRecipient
}`
`${signedCeloTransaction.gatewayFeeRecipient} expected ${celoTransaction.gatewayFeeRecipient}`
)
expect(signedCeloTransaction.gatewayFeeRecipient!.toLowerCase()).toEqual(
celoTransaction.gatewayFeeRecipient.toLowerCase()
Expand Down
8 changes: 5 additions & 3 deletions packages/contractkit/src/wrappers/Attestations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ function parseGetCompletableAttestations(response: GetCompletableAttestationsRes
(response[3] as unknown) as string
)

return zip3(response[0].map(valueToInt), response[1], metadataURLs).map(
([blockNumber, issuer, metadataURL]) => ({ blockNumber, issuer, metadataURL })
)
return zip3(
response[0].map(valueToInt),
response[1],
metadataURLs
).map(([blockNumber, issuer, metadataURL]) => ({ blockNumber, issuer, metadataURL }))
}

const stringIdentity = (x: string) => x
Expand Down
8 changes: 7 additions & 1 deletion packages/contractkit/src/wrappers/Governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,13 @@ export class GovernanceWrapper extends BaseWrapper<Governance> {
if (!queue) {
queue = await this.getQueue()
}
return { index: this.getIndex(proposalID, queue.map((record) => record.proposalID)), queue }
return {
index: this.getIndex(
proposalID,
queue.map((record) => record.proposalID)
),
queue,
}
}

private async lesserAndGreater(proposalID: BigNumber.Value, _queue?: UpvoteRecord[]) {
Expand Down
4 changes: 2 additions & 2 deletions packages/faucet/src/contracts/types/Escrow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export class Escrow extends Contract {

sentPaymentIds(arg0: string, arg1: number | string): TransactionObject<string>

getReceivedPaymentIds(identifier: string | number[]): TransactionObject<(string)[]>
getReceivedPaymentIds(identifier: string | number[]): TransactionObject<string[]>

getSentPaymentIds(sender: string): TransactionObject<(string)[]>
getSentPaymentIds(sender: string): TransactionObject<string[]>

renounceOwnership(): TransactionObject<void>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import androidx.test.rule.ActivityTestRule;
import com.wix.detox.Detox;
import org.junit.Rule;
import org.junit.runner.RunWith;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
@LargeTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.celo.mobile;

import android.os.Bundle;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactFragmentActivity;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import java.util.Date;
import org.devio.rn.splashscreen.SplashScreen;
Expand Down
Loading

0 comments on commit a90d747

Please sign in to comment.