wallets: accept base58/base64 Solana serializedTransaction + re-export web3.js types#1978
wallets: accept base58/base64 Solana serializedTransaction + re-export web3.js types#1978alfonso-paella wants to merge 1 commit into
Conversation
Co-Authored-By: Alfonso <alfonso@paella.dev>
Original prompt from Alfonso
|
🦋 Changeset detectedLatest commit: 3993ce5 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 |
🤖 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:
|
Description
Two Solana DX fixes from a customer integrating Solana smart wallets + Jupiter.
1.
serializedTransactionencoding trap. The Crossmint API'sparams.transactionexpects base58 —SolanaWallet.sendTransactionbs58-encodes when you pass aVersionedTransactionobject, but when you passserializedTransaction: stringit forwarded the value untouched, so base58 was silently required and undocumented. Jupiter returns base64, so those strings failed. (The README even wrongly documented<base64-encoded-transaction>.)We now auto-detect and normalize. A new util deserializes to validate, so detection is unambiguous:
base58 is tried first, so existing base58 callers are unaffected. JSDoc on
SolanaTransactionInput.serializedTransaction/sendTransactionand the README now state both encodings are accepted.2.
@solana/web3.jstype clash.@solana/web3.jswas pinned exactly (1.98.1) independencieswhile also declared as a peer (^1.98.1). The exact pin makes package managers install a duplicate nested copy for consumers on a different1.98.x, so their app'sVersionedTransactionis not assignable to the SDK's. Least-disruptive, non-breaking fix:dependenciesrange to^1.98.1(matches the peer range) so it dedupes to the consumer's copy.VersionedTransaction,SolanaTransaction,SolanaKeypair,SolanaPublicKey(aliased to avoid clashing with the SDK's ownTransaction).Breaking-change note: the fully robust single-copy guarantee would be to make
@solana/web3.jspeer-only (drop it fromdependencies). That is a breaking change — the SDK imports web3.js at runtime in several signer files, so consumers not already installing it would break — so it was intentionally avoided in favor of the caret relax + re-export.Test plan
normalizeSolanaSerializedTransaction: base58 returned unchanged, base64 converted to the expected base58, invalid input throws.SolanaWallettests: base58 pass-through + a base64 input asserting the API receives the base58 encoding. Test helpercreateMockSolanaSerializedTransactionnow builds a real deserializableVersionedTransaction.pnpm --filter @crossmint/wallets-sdk... build,pnpm --filter @crossmint/wallets-sdk test:vitest(652 passed), andpnpm lintall pass locally.Package updates
@crossmint/wallets-sdk— minor. Changeset added (.changeset/solana-transaction-encoding.md).Link to Devin session: https://crossmint.devinenterprise.com/sessions/ef97ae75e32647d8a1aae862ed5f86b8
Requested by: @alfonso-paella