-
Notifications
You must be signed in to change notification settings - Fork 973
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
Updates & revamps ParticleAdapter #840
Conversation
Quick bump |
GM @jordansexton! Happy to make any changes here if needed; all updates here have been tested and are working as of this week. |
GM! Going to followup again here quickly if possible; would be awesome to have a review in the next few days as we'll be making a big Solana push soon, in which this update to our adapter is a key component. Apologies for the repeated bumps, just a bit important~ let me know if there's anything we can do to help make reviewing a bit easier @jordaaash; thank you! |
Hey @TABASCOatw, sorry for the delay here! I'm trying to build this locally to test but I'm getting some build errors. From your branch I ran
For the first one, the version of The other errors look like Typescript errors in the adapter code which will need to be fixed before we can merge this. Are you seeing the same |
No top level dependency changes detected. Learn more about Socket for GitHub ↗︎ |
Hey @mcintyre94! Thank you so much for your initial testing here. I went ahead and fixed the issues you mentioned (the TS errors and lack of This includes the requirement of a few new dependencies, as listed by the other comment on this PR. A few small changes were made to |
Thanks for those updates @TABASCOatw, it's now building for me locally. I've tried adding it to the example app in the wallet-adapter repo, by just adding When I connect to Particle, I get an error: "WalletConfigError: Param error, see doc for more info" Using a debugger the underlying error being thrown is I'm guessing that there's maybe some required config to use this adapter? Could you provide an example config that I can use to test it please? If that is the issue then it'd be worth updating your adapter's constructor to require the config, so that not providing it becomes a type error. https://github.com/solana-labs/wallet-adapter/blob/621a845fc17dab5254e4566ab97e39fb513dc5c1/packages/wallets/particle/src/adapter.ts#L74 Also please could you commit the pnpm-lock.yaml file? You should have some changes on your branch as a result of the package.json file you changed. The CI requires this to be updated whenever any dependencies change. |
Hey @mcintyre94, sure, no problem at all! Just made those changes. As for the config, feel free to use this setup: return new ParticleAdapter({
config: {
projectId: '3e63e8c0-1df6-4efb-a96e-96836accebdc',
clientKey: 'cx5kWWPJ0AmG80U6ePLJ3U3EpEknGBYeVlWdF4xv',
appId: 'c98e6688-ffea-4a66-8282-f3c7b52c012a',
},
}); |
Hey @TABASCOatw thanks for that config! Is that definitely configured as a Solana project? When I try to connect, I now get the Particle UI, but I get an error "WalletConnectionError: Non-base58 character" Looking into the this.auth.on("connect", (userInfo2) => {
const wallet = userInfo2.wallets.find((w) => w.chain_name === "solana" && w.public_address.length > 0);
if (wallet) {
this._publicKey = new import_web3.PublicKey(wallet.public_address);
this.events.emit("connect", this._publicKey);
}
}); And in localstorage I'm seeing a field with key [
{
"uuid": "6fe39d83-b3a6-4c31-af4c-a0895fb18337",
"chain_name": "evm_chain",
"public_address": "0xBdB1285F8d3aa4Bb04A88E93c1c8DC46C9b3f579"
}
] So I think something is generating an EVM address and then trying to pass it to the Solana web3.js Separately there's a type error introduced by the most recent changes: src/adapter.ts:80:11 - error TS2322: Type 'NestedConfig | undefined' is not assignable to type 'NestedConfig'.
Type 'undefined' is not assignable to type 'NestedConfig'.
80 const nestedConfig: NestedConfig = config.config; |
Ah okay I see what's going on, that build error meant I was on an earlier version locally and the Fixing that type error locally by using Let me just take a look at the code and then we should be able to get this merged :) |
@@ -1,175 +1,277 @@ | |||
import type { Config, ParticleNetwork, SolanaWallet } from '@particle-network/solana-wallet'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment: please run pnpm lint:fix
from the root. There are a bunch of prettier issues but that should fix them all.
projectId?: string; | ||
clientKey?: string; | ||
appId?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these actually optional? If I comment any of them out I get that param error again
|
||
export interface ParticleAdapterConfig { | ||
config?: Config; | ||
config?: NestedConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, I don't think this is actually optional? If it isn't then that'll fix the type error too, as well as being much clearer for devs how to use this adapter
this.icon = await import( | ||
`./${preferredAuthType.type}.ts` | ||
).then((module) => module.default); | ||
console.log(this.icon); | ||
} catch (error) { | ||
console.error(`Could not import icon: ${error}`); | ||
} | ||
})(); | ||
this.name = (preferredAuthType.type.charAt(0).toUpperCase() + | ||
preferredAuthType.type.slice(1)) as WalletName<any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're also concerned about this functionality. We can't really have "Github" for example showing in the wallet modal, we need users to be able to trust what is displayed here at least by the wallets that we publish from this repo
It needs to be clear in all cases that the user is connecting to Particle wallet
We also can't use other people's logos here
I'm back in the office now. I'm sorry for all the time that was spent on this PR and its review, but we cannot accept it. The proposed adapter includes multiple dependencies, including icons, which it loads in the constructor. This is not allowed in any adapter that we publish. Adapters that we publish that asynchronously load an SDK may only load one SDK, may only do it on connection, and may only include one dependency to do so. Adapters may not include multiple icons, change the name or icon used, or use names or icons of other services besides the wallet. A user can connect to your wallet's adapter with a canonical name and icon, and then after that you can display social login options or anything else your wallet may display. For these reasons, we can't publish this adapter, or provide further review of it. For adapters that we cannot accept, we encourage self-publishing with your own NPM package where you can fully decide what to load, when to load it, and what the behavior will be. Additionally, instead of publishing an adapter, we encourage you to publish a smaller library to register a |
@jordaaash Understood, thank you for the update! In this case, would it be possible to open a separate PR purely updating the package version and fixing |
Yes definitely, happy to accept a PR if the current SDK isn't working. |
Perfect, thank you! Just opened #854 |
ParticleAdapter
is the adapter for an MPC-TSS Wallet-as-a-Service provider, Particle Network.This adapter was quite out of date, and thus configuration (through
config
on a new instance ofParticleAdapter
) didn't work and was incompatible with the current Particle dashboard. This has been fixed through:@particle-network/solana-wallet
This has been tested and is functional, enabling the standard level of configuration possible with modern implementations of Particle (customizing UI, choosing wallet popup options, etc.)
In addition to this, functionality has been introduced to select
preferredAuthType
when addingParticleAdapter
to a list of wallets.preferredAuthType
can either be a string or an object containingtype
and booleansetAsDisplay
preferredAuthType
dictates ifParticleAdapter
automatically routes to a specific mechanism of wallet authentication (social login). IfpreferredAuthType
is set to an object withsetAsDisplay
as true, Particle will display in the wallet connection list corresponding to the selected social login provider, indicating the shortcut. Otherwise ifsetAsDisplay
is set to false or ifpreferredAuthType
is undefined/a string, authentication will be handled within a genericParticle
option according to the status ofpreferredAuthType
.