fix(wallets): skip device signer injection for Solana wallets#1826
fix(wallets): skip device signer injection for Solana wallets#1826devin-ai-integration[bot] wants to merge 2 commits into
Conversation
The SDK was unconditionally injecting a device signer during wallet creation when deviceSignerKeyStorage was available. This caused 400 errors for Solana wallets using the Squads provider, which does not support device signers. ensureDeviceSignerInSigners now checks the chain and skips injection for Solana, where device signer support is not yet broadly available.
Original prompt from Robin
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: f0588fb The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
packages/wallets/src/wallets/wallet-factory.ts:257-270
The `chain` parameter is redundant here since it's already accessible as `args.chain`. Passing it separately requires the caller to remember to keep them in sync, which is error-prone and adds noise to the signature.
```suggestion
private ensureDeviceSignerInSigners<C extends Chain>(
args: WalletCreateArgs<C>
): Array<SignerConfigForChain<C> | ExternalWalletRegistrationConfig> {
if (args.chain === "solana") {
return args.signers ?? [];
}
const signers = args.signers ?? [];
const hasDeviceSigner = signers.some((s) => s.type === "device");
if (!hasDeviceSigner) {
return [...signers, { type: "device" } as SignerConfigForChain<C>];
}
return signers;
}
```
### Issue 2 of 2
packages/wallets/src/wallets/wallet-factory.ts:131
Call-site update to match the simplified signature (removing the now-redundant `chain` argument).
```suggestion
? this.ensureDeviceSignerInSigners(validatedArgs)
```
Reviews (1): Last reviewed commit: "fix(wallets): skip device signer injecti..." | Re-trigger Greptile |
| const signersWithDevice = | ||
| validatedArgs.options?.deviceSignerKeyStorage != null | ||
| ? this.ensureDeviceSignerInSigners(validatedArgs) | ||
| ? this.ensureDeviceSignerInSigners(validatedArgs.chain, validatedArgs) |
There was a problem hiding this comment.
Call-site update to match the simplified signature (removing the now-redundant
chain argument).
| ? this.ensureDeviceSignerInSigners(validatedArgs.chain, validatedArgs) | |
| ? this.ensureDeviceSignerInSigners(validatedArgs) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/wallets/src/wallets/wallet-factory.ts
Line: 131
Comment:
Call-site update to match the simplified signature (removing the now-redundant `chain` argument).
```suggestion
? this.ensureDeviceSignerInSigners(validatedArgs)
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Good catch you cold-blooded code crawler 🐍 — applied in f0588fb. The redundant param has shed its skin.
|
Reviews (2): Last reviewed commit: "refactor: remove redundant chain paramet..." | Re-trigger Greptile |
Description
CrossmintWalletProvideralways creates anIframeDeviceSignerKeyStorage, which causesWalletFactory.createWalletto unconditionally inject a{ type: "device" }signer into the wallet creation request viaensureDeviceSignerInSigners. For Solana wallets using the Squads provider (the current default), the backend rejects this with a 400 error: "Device signers are not currently supported for this Solana wallet."This PR makes
ensureDeviceSignerInSignerschain-aware: whenchain === "solana", the method skips automatic device signer injection and returns the user-provided signers as-is. EVM wallets continue to get device signers injected automatically.Note: if a consumer explicitly includes a device signer in their
signersarray (e.g. for a swig/crossmint-provider Solana wallet), it will still be passed through — only the automatic injection is skipped.Related: wallets-quickstart#18 (switches quickstart default chain from solana → base-sepolia)
Human review checklist
Test plan
Package updates
@crossmint/wallets-sdk: patch — changeset added via.changeset/skip-device-signer-solana.mdLink to Devin session: https://crossmint.devinenterprise.com/sessions/f538ed0c51a24bf8b61461a597f92487
Requested by: @jcurbelo