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

Refactor to Accounts.sol #1392

Merged
merged 50 commits into from
Oct 31, 2019
Merged

Refactor to Accounts.sol #1392

merged 50 commits into from
Oct 31, 2019

Conversation

nambrot
Copy link
Contributor

@nambrot nambrot commented Oct 17, 2019

Description

This PR extracts common account/authorization logic into a single smart contract

  • Contract migrations
  • ContractKit
  • Celotool
  • CLI/docs
  • event emission
  • Remove name/url from Validators

Tested

  • Unit tests

Related issues

Backwards compatibility

This change will be breaking for all clients

@nambrot nambrot requested review from asaj and m-chrzan as code owners October 17, 2019 21:41
@nambrot nambrot requested a review from mcortesi as a code owner October 18, 2019 18:21
@codecov
Copy link

codecov bot commented Oct 18, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1392   +/-   ##
=========================================
  Coverage          ?   73.61%           
=========================================
  Files             ?      277           
  Lines             ?     7443           
  Branches          ?      956           
=========================================
  Hits              ?     5479           
  Misses            ?     1852           
  Partials          ?      112
Flag Coverage Δ
#mobile 73.61% <ø> (?)

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 3c86fef...073a20b. Read the comment docs.


interface IAccounts {
function isAccount(address) external view returns (bool);
function getAccountFromVoteSigner(address) external view returns (address);
Copy link
Contributor

Choose a reason for hiding this comment

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

how do you feel about "voteSignerToAccount()" naming style?

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 feel ok with any naming, happy to go with whatever y'all think is best @asaj

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm easy

function isAccount(address) external view returns (bool);
function getAccountFromVoteSigner(address) external view returns (address);
function getAccountFromValidationSigner(address) external view returns (address);
function getValidationSignerFromAccount(address) external view returns (address);
Copy link
Contributor

Choose a reason for hiding this comment

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

being that we are in the "Accounts" contract, i feel unnecessary to have the FromAccount suffix here; how about getValidationSigner(account)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed

function getAccountFromValidationSigner(address) external view returns (address);
function getValidationSignerFromAccount(address) external view returns (address);
function getAccountFromAttestationSigner(address) external view returns (address);
function getAttestationSignerFromAccount(address) external view returns (address);
Copy link
Contributor

Choose a reason for hiding this comment

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

same

* @param attestationSigner The address of the signing key to authorize.
* @return A CeloTransactionObject
*/
async authorizeAttestationSigner(
Copy link
Contributor

Choose a reason for hiding this comment

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

For a future PR, we can have a authorizeSigner(role, account, signer)

* @param account The address of the account.
* @return The address with which the account can vote.
*/
getVoteSignerFromAccount: (account: string) => Promise<Address> = proxyCall(
Copy link
Contributor

@mcortesi mcortesi Oct 23, 2019

Choose a reason for hiding this comment

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

for a future PR, maybe have a getSigner(role, account)

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 was trying to think about how to make them work without having to effectively do a bunch of if statements that match on the role in solidity (which I imagine would make this more inefficient.). Did you have any rough idea here?

Copy link
Contributor

Choose a reason for hiding this comment

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

if you want to avoid the evil if, maybe you can use a Map<Role,Function>

const getters = {
   [Role.Voter]: this.contract.method.getVoteSignerFromAccount,
   ...
}

return getters[role](account)

would check about if it needs the bind(this.contract.methods)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nvm, I thought this comment was on the solidity contract, not on the wrapper itself

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 added it for the authorize functions, but didn't feel like it was appropriate here as just using the direct methods seemed preferrable to me

@@ -22,7 +22,7 @@ export default class RegisterMetadata extends BaseCommand {
async run() {
const { flags } = this.parse(RegisterMetadata)
this.kit.defaultAccount = flags.from
const attestations = await this.kit.contracts.getAttestations()
await displaySendTx('registerMetadata', attestations.setMetadataURL(flags.url))
const accounts = await this.kit.contracts.getAccounts()
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this cmd should be part of accounts:...

@@ -18,8 +18,8 @@ export default class GetMetadata extends BaseCommand {
async run() {
const { args } = this.parse(GetMetadata)
const address = args.address
const attestations = await this.kit.contracts.getAttestations()
const metadataURL = await attestations.getMetadataURL(address)
const accounts = await this.kit.contracts.getAccounts()
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this should be part of accounts:...

@mrsmkl mrsmkl mentioned this pull request Oct 30, 2019
5 tasks
nambrot added a commit to celo-org/celo-blockchain that referenced this pull request Oct 31, 2019
@nambrot nambrot merged commit 9c6495d into master Oct 31, 2019
nambrot added a commit to celo-org/celo-blockchain that referenced this pull request Oct 31, 2019
* Adjust new interface from celo-org/celo-monorepo#1392

* Remove URL

* Point e2e tests to nambrot/accounts
@nambrot nambrot mentioned this pull request Oct 31, 2019
aaronmgdr added a commit that referenced this pull request Nov 2, 2019
* master: (62 commits)
  Fix e2e on CI (#1537)
  Allow a specified address to disable/enable the Exchange  (#1467)
  Avoid re-encrypting key files with yarn keys:encrypt command (#1560)
  Support protocol hotfixing (#613)
  Point e2e tests back (#1562)
  Refactor to Accounts.sol (#1392)
  Add selectIssuers Transaction (#1327)
  [Wallet] Get React Native Hot Reloading Working (#1551)
  Unify to prefix messages for signing (#1473)
  [Wallet] Improve error handling around account creation and keystore ops (#1497)
  Add CI test for checking licenses and misc package.json cleanup (#1550)
  [Wallet] Implement SMS invite on iOS (#1541)
  CI: brings back to master (#1554)
  Validators: uses Ethereum address for proof of possession (#1494)
  Validate Attestation Requests (#1468)
  Rename hosted node references to forno (#1511)
  Bump rubyzip from 1.2.3 to 1.3.0 in /packages/mobile (#1508)
  Added txpool family to geth apis. Sorted geth cmd options (#1462)
  [Wallet] Fix yarn dev command for running android (#1534)
  [Wallet] iOS info plist changes and version bump (#1539)
  ...

# Conflicts:
#	yarn.lock
@mcortesi mcortesi deleted the nambrot/accounts branch December 4, 2019 16:48
aaronmgdr added a commit that referenced this pull request Dec 5, 2019
* master: (73 commits)
  Fix Ethstats Image reference (#1577)
  EU Cookies Behavior Change (#1447)
  [verifier] Upgrade to RN 61 (#1572)
  [Wallet] Update link styles and Implement VerificationEducationScreen (#1565)
  [wallet] Added native phone picker (#1310)
  [Wallet] Set up new verification screen skeletons (#1563)
  Bump e2e test migrate numbers where needed (#1567)
  [Wallet] Create new carousel component (#1555)
  [Wallet] Protect Backup Key and Safeguards with PIN (#1556)
  Increase ganache gas limit (#1569)
  Re-work locked gold requirements for validators and groups (#1474)
  Fix e2e on CI (#1537)
  Allow a specified address to disable/enable the Exchange  (#1467)
  Avoid re-encrypting key files with yarn keys:encrypt command (#1560)
  Support protocol hotfixing (#613)
  Point e2e tests back (#1562)
  Refactor to Accounts.sol (#1392)
  Add selectIssuers Transaction (#1327)
  [Wallet] Get React Native Hot Reloading Working (#1551)
  Unify to prefix messages for signing (#1473)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Developers SBAT reference an Accounts smart contract
3 participants