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

feat(web-components): allow custom signer instead of keplr #81

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

samsiegart
Copy link
Contributor

@samsiegart samsiegart commented Feb 7, 2024

refs Agoric/agoric-sdk#8813

Also now exports the amino converters and registry types for clients that use custom signers, and did some refactoring to clean up.

Tested the existing keplr connection flow in dapp-inter using yarn link to check for regressions.

Copy link
Member

@0xpatrickdev 0xpatrickdev left a comment

Choose a reason for hiding this comment

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

Looks good. Left some small suggestions but none are blockers.

Would suggest updating the README.md to include the latest exports and a quick blurb on how to provide a custom signer.

Comment on lines +6 to +8
agoricRegistryTypes,
agoricConverters,
} from './src/wallet-connection/signerOptions.js';
Copy link
Member

Choose a reason for hiding this comment

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

Nice, glad to see to see these exported. Should we also update the README to include this?

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 think I'd like to land the react-components stuff first so we can have a more cohesive view/example

Comment on lines +69 to +79
const b64address = toBase64(toAccAddress(address));

const act1 = {
typeUrl: AgoricMsgs.MsgProvision.typeUrl,
value: {
address: b64address,
nickname: 'my wallet',
powerFlags: [PowerFlags.SMART_WALLET],
submitter: b64address,
},
};
Copy link
Member

Choose a reason for hiding this comment

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

Worth exporting makeProvisionSmartWalletMsg(address) along with the types and converters?

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 not sure why someone would need this exported if they can just use the wallet connection object. I could be convinced otherwise, but wanted to keep these changes as minimal as possible for the goal of the wallet connection thing. Ditto for makeWalletSpendMsg

Copy link
Member

Choose a reason for hiding this comment

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

Thinking here was to have exports for folks in this camp, but don't feel strongly about it. Maybe these folks can use @agoric/cosmic-proto which is being updated to use telescope.

My intention is if someone's using a signer for non-agoric stuff also, they should provide their own signing client with the help of agoricRegistryTypes/agoricConverters.

Comment on lines +105 to +111
const act1 = {
typeUrl: AgoricMsgs.MsgWalletSpendAction.typeUrl,
value: {
owner: toBase64(toAccAddress(address)),
spendAction,
},
};
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, worth exporting makeWalletSpendMsg(address, spendAction)?

* @param {string} chainId
* @param {string} rpc
*/
export const connectKeplr = async (chainId, rpc) => {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add aminoTypes and registry as arguments with default values? accountParser is another thing a developer may want exposed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't exported in the package level, it's just a backward-compatible default in case clientConfig isn't provided. My intention is if someone's using a signer for non-agoric stuff also, they should provide their own signing client with the help of agoricRegistryTypes/agoricConverters. If there's any accountParser stuff specific to agoric that we're missing we should provide that here though, is there?

Copy link
Member

Choose a reason for hiding this comment

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

Correct nothing specific from agoric wrt to account parser. But if someone is using this signer implementation to connect to other chains, like Agoric/wallet-app#128, they might need one.

More in general, if I'm a library author and wrapping something that takes options, I like to expose those options to the consumer to give more them flexibility and the code a longer shelf life.

@samsiegart samsiegart merged commit 2d4c3bc into main Feb 20, 2024
1 check passed
@samsiegart samsiegart deleted the custom-signer branch February 20, 2024 17:46
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.

2 participants