8000 Updated Keyring Controller by kautukkundan · Pull Request #85 · getwax/bls-wallet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Updated Keyring Controller #85

Merged
merged 3 commits into from
Jan 12, 2022
Merged

Updated Keyring Controller #85

merged 3 commits into from
Jan 12, 2022

Conversation

kautukkundan
Copy link
Contributor
@kautukkundan kautukkundan commented Jan 6, 2022

What is this PR doing?

updated bls-wallet-clients version
added methods create and import BLS accounts
updated KeyringController interface
added method to sign transactions

How can these changes be manually tested?

Does this PR resolve or contribute to any issues?

Checklist

  • I have manually tested these changes
  • Post a link to the PR in the group chat

Guidelines

  • If your PR is not ready, mark it as a draft
  • The resolve conversation button is for reviewers, not authors
    • (But add a 'done' comment or similar)

  added methods create and import BLS accounts
  updated KeyringController interface
  added method to sign transactions
@github-actions github-actions bot added the extension Browser extension related label Jan 6, 2022
}

private _getContractWalletAddress(privateKey: string) {
const provider = new ethers.providers.JsonRpcProvider(PROVIDER_URL);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this provider come from other controllers?
the SafeEventEmitterProvider used by other controllers isn't compatible with this

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to use one ethers.js provider and pass that down, as this may create additional socket connections/network request overhead. For now though to get it working should be okay.

Also, you use CHAIN_RPC_URL instead of adding a new env var. PROVIDER_URL === CHAIN_RPC_URL.

Suggested change
const provider = new ethers.providers.JsonRpcProvider(PROVIDER_URL);
const provider = new ethers.providers.JsonRpcProvider(CHAIN_RPC_URL);

Copy link
Contributor

Choose a reason for hiding this comment

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

it should be the provider coming from other controllers.
it is an eip-1193 compatible provider.

}

private _getContractWalletAddress(privateKey: string) {
const provider = new ethers.providers.JsonRpcProvider(PROVIDER_URL);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to use one ethers.js provider and pass that down, as this may create additional socket connections/network request overhead. For now though to get it working should be okay.

Also, you use CHAIN_RPC_URL instead of adding a new env var. PROVIDER_URL === CHAIN_RPC_URL.

Suggested change
const provider = new ethers.providers.JsonRpcProvider(PROVIDER_URL);
const provider = new ethers.providers.JsonRpcProvider(CHAIN_RPC_URL);

Comment on lines 103 to 107
private async _getBLSSinger() {
return initBlsWalletSigner({
chainId: Number(this.state.chainId),
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of initing and handling signing via the BLS signer directly, you may just want to use the BlsWalletWrapper abstraction instead and add it into the state. I am unsure if the state needs to have only primitively typed data in it, if so you may be able to use another controller/construct to manage BlsWalletWrapper wallet objects.

You then would only need to call BlsWalletWrapper.connect once and then store the wallet object it returns and use that for signing/address operations. See https://github.com/jzaki/bls-wallet/tree/main/contracts/clients#blswalletwrapper for details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

semi-fixed in f30cd85

Yeah I agree. As the prev comment mentions, should use the provider coming from the state. Couldn't because of incompatibility. Would be nice to get @chaitanyapotti's opinion on how to pass the provider to each controller.

Also @jacque006, the wrapper currently has a private constructor and static connect and address methods. It wont be possible to create an object (with only provider and verification address), save it in state and just use different privKeys to do different ops. WDYT about adding these to the client library itself?

Copy link
Collaborator

Choose a reason for hiding this comment

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

connect is essentially the async constructor for BLSWalletWrapper as it returns an initialized BLSWalletWrapper object. You would need to connect for each private key and store the wrapper object for each wallet.

I think rolling with the static methods for now is fine per our offline conversation. But it may be easier in the future to have a common place the BLSWalletWrapper object(s) can be accessed from.

@voltrevo
Copy link
Collaborator
voltrevo commented Jan 9, 2022

@kautukkundan I see you checked "I have manually tested these changes", but I don't understand what manual testing you could have done and you haven't written anything for that section. Could you clarify?

Copy link
Collaborator
@voltrevo voltrevo left a comment

Choose a reason for hiding this comment

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

8000

Looks sensible to me. I think you need to implement @jacque006's point about a shared ethers provider though and use CHAIN_RPC_URL instead of creating a new environment variable.

I'd also like @chaitanyapotti to give this a once-over since the target is his wip branch. I also imagine he'd be your best bet for doing the shared provider if there's any complications with that.

Once those things are taken care of let's get this merged.

updated wallet-client version
removed extra env var PROVIDER_URL
@kautukkundan
Copy link
Contributor Author

ah @voltrevo manually tested on local terminal by importing modules and checking the returned values.

Copy link
Collaborator
@jacque006 jacque006 left a comment

Choose a reason for hiding this comment

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

One other set of suggested changes, but I'm good 🚢 ing this as is. We can figure out provider/wallet object issues in a later piece of work.

@voltrevo
Copy link
Collaborator

ah @voltrevo manually tested on local terminal by importing modules and checking the returned values.

Ohh nice 👍

@kautukkundan kautukkundan merged commit c3eb07c into feat/inpage-provider Jan 12, 2022
@kautukkundan kautukkundan deleted the kk/keyring branch January 12, 2022 10:22
@chaitanyapotti
Copy link
Contributor

ethers is a very heavy library.
Provider must satisfy an interface for bls-wallet-client instead of being an instance of ethers dependency

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extension Browser extension related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0