Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support claim signatures and support Keybase claims #1575

Merged
merged 12 commits into from
Nov 11, 2019

Conversation

nambrot
Copy link
Contributor

@nambrot nambrot commented Nov 4, 2019

Description

This PR adds the ability to claim Keybase accounts. It also requires claims to be signed by the claiming account, and that is enforced during the parsing of metadata.

A user can claim a keybase account by running:
celocli account:claim-keybase ./namtest.json --username nambrot --from 0x13897F87A0aB80824fa85600b935dAF579b69157

If the keybase CLI is installed, we will automatically attempt to upload the proof to the keybase file system, otherwise, we'll print manual instructions such as:

Proving a keybase claim requires you to publish the signed claim on your Keybase file system to prove ownership. We saved it for you under verify-0x13897F87A0aB80824fa85600b935dAF579b69157.json. It should be hosted in your public folder at .well-known/celo//verify-0x13897F87A0aB80824fa85600b935dAF579b69157.json, so that it is available under https://nambrot.keybase.pub/.well-known/celo/verify-0x13897F87A0aB80824fa85600b935dAF579b69157.json

Tested

  • Ran locally

Related issues

@codecov
Copy link

codecov bot commented Nov 5, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@2b3eb0b). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1575   +/-   ##
=========================================
  Coverage          ?   74.15%           
=========================================
  Files             ?      287           
  Lines             ?     7652           
  Branches          ?      667           
=========================================
  Hits              ?     5674           
  Misses            ?     1865           
  Partials          ?      113
Flag Coverage Δ
#mobile 74.15% <ø> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b3eb0b...af22327. Read the comment docs.

Copy link
Contributor

@mcortesi mcortesi left a comment

Choose a reason for hiding this comment

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

lefts some comments, but in general everything is good.

Maybe we can add tests to the cli commands, they don't seem to be as "small" as usual.
For testing cli commands, i've added support for them in another pr which is about to be merged. Basically you can run a command using ganache/devchain same as contractkit

packages/cli/src/commands/account/claim-keybase.ts Outdated Show resolved Hide resolved
packages/cli/src/utils/exec.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,52 @@
import { spawn, SpawnOptions } from 'child_process'

export function execCmd(
Copy link
Contributor

Choose a reason for hiding this comment

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

at this point... having so many instances of this fn, shouldn't we move it to celo-utils?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should, but I'm not sure I want to be the person transforming the codebase, nor prescribe which version should be the one to rule them all

packages/contractkit/src/identity/claims/keybase.ts Outdated Show resolved Hide resolved
packages/utils/src/address.ts Show resolved Hide resolved
@@ -59,3 +59,8 @@ export function failWith(msg: string): never {
console.error(msg)
return process.exit(1)
}

export async function binaryPrompt(promptMessage: string) {
const resp = await cli.prompt(promptMessage)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a fixed "[y/yes, n/no]" as a prompt suffix?

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't if oclif has it, but a good library for this kind of things is inquirer.js

@mcortesi mcortesi assigned nambrot and unassigned mcortesi Nov 7, 2019
@nambrot nambrot assigned mcortesi and unassigned nambrot Nov 8, 2019
Copy link
Contributor

@mcortesi mcortesi left a comment

Choose a reason for hiding this comment

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

great tests!! ;)

}

test('account:create-metadata cmd', async () => {
const newFilePath = `${tmpdir()}/newfile.json`
Copy link
Contributor

Choose a reason for hiding this comment

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

don't you need to remove the file if already present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but I'm just assuming that it does not exist :)

test('account:create-metadata cmd', async () => {
const newFilePath = `${tmpdir()}/newfile.json`
await CreateMetadata.run(['--from', account, newFilePath])
const res = JSON.parse(readFileSync(newFilePath).toString())
Copy link
Contributor

Choose a reason for hiding this comment

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

something that you can do is use jest snapshot testing which is a nice way of doing a quick test that asserts the content remains the same over different runs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm gonna leave that for a future PR :)

@mcortesi mcortesi assigned nambrot and unassigned mcortesi Nov 8, 2019
@mcortesi
Copy link
Contributor

mcortesi commented Nov 8, 2019 via email

@nambrot nambrot added the automerge Have PR merge automatically when checks pass label Nov 11, 2019
@celo-ci-bot-user celo-ci-bot-user merged commit 2664e2b into master Nov 11, 2019
@celo-ci-bot-user celo-ci-bot-user deleted the nambrot/keybase-metadata branch November 11, 2019 19:47
aaronmgdr added a commit that referenced this pull request Nov 14, 2019
* master: (56 commits)
  Adjust e2e transfer and governance tests to match new fee distribution and eliminate ProposerFraction (#1585)
  [Wallet] Add more local currencies (#1698)
  Switch to correct cluster when fauceting (#1687)
  [Wallet] Use the country of the phone number for determining the default local currency (#1684)
  [Wallet] Limit QR code scanner to 1 code per second (#1676)
  Update Dark backgrounds text color (#1677)
  Remove integration sync test
  Minor attestation service fixes (#1680)
  [wallet] Fixed Native phone picker Use native API instead (#1669)
  Fix token addresses for notification service (#1674)
  Add golang to setup docs
  [wallet] Hide invite education copy after invite was redeemed (#1670)
  [Wallet] Add spinner, timer, and tip text to Verification input screen (#1656)
  [Wallet] Fix app deprecation check mechanism (#1358)
  Point end-to-end governance test back to master (#1665)
  Add EpochRewards smart contract to calculate epoch rewards and payments (#1558)
  Optimized Attestation view calls and removal of the reveal TX (#1578)
  Support claim signatures and support Keybase claims (#1575)
  [Wallet] Add timestamp to top banner messages (#1657)
  Export geth metrics on VM testnet (#1351)
  ...

# Conflicts:
#	yarn.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ContractKit: Create and verify a keybase claim Add address to claim metadata
4 participants