fix: pass undefined instead of empty object for signOptions in ChainWalletStore - #42
Conversation
…alletStore
Fix `ChainWalletStore.getOfflineSigner()` passing `{}` instead of `undefined` as `signOptions` to `cosmosWallet.signAmino()` and `cosmosWallet.signDirect()`.
Problem
CosmosWallet in core defines defaultSignOptions = { preferNoSetFee: true } and applies them via signOptions || this.defaultSignOptions. Since {} is truthy, the fallback never triggers and the defaults are silently dropped.
Without preferNoSetFee: true, Keplr overrides the application-provided fee with its own calculation using the chain's native denom. This breaks any app that pays fees in a non-native denomination.
Fix
Pass undefined instead of {} for both signAmino and signDirect so the defaults in core are respected.
There was a problem hiding this comment.
Thanks for this fix — and sorry for the long wait. The change itself is correct: CosmosWallet.signAmino/signDirect fall back with signOptions || this.defaultSignOptions, so a truthy {} silently drops preferNoSetFee: true and Keplr overrides the app's fee. Passing undefined restores the defaults. I also grepped for other {} signOptions call sites; the only other one is wallets/ledger/src/cosmos.ts, which is Ledger's own signer and not affected.
One blocker: two existing unit tests still assert the old {} argument, so pnpm test fails on this branch (merged onto current main; main itself is green):
packages/store test: ● ChainWalletStore › Offline Signer › should handle signAmino calls
packages/store test: ● ChainWalletStore › Offline Signer › should handle signDirect calls
- Expected {}
+ Received undefined
Fix: in packages/store/__tests__/chain-wallet-store.test.ts, change the 4th expected argument of both toHaveBeenCalledWith(...) assertions from {} to undefined. With that change the full suite passes (store: 176/176). A ready-made version of that 2-line test update is on branch devin/1790884011-pr42-fixup (commit ea669dc) if the maintainers prefer to land it alongside this PR.
Non-blocking follow-up idea for maintainers: making CosmosWallet merge options ({ ...this.defaultSignOptions, ...signOptions }) instead of || would stop any caller from accidentally dropping the defaults by passing a partial object.
Reviewed by Devin on behalf of @pyramation
fix(store): preserve CosmosWallet default signOptions in getOfflineSigner (#42 + test update)
Fix
ChainWalletStore.getOfflineSigner()passing{}instead ofundefinedassignOptionstocosmosWallet.signAmino()andcosmosWallet.signDirect().Problem
CosmosWalletin core definesdefaultSignOptions = { preferNoSetFee: true }and applies them viasignOptions || this.defaultSignOptions. Since{}is truthy, the fallback never triggers and the defaults are silently dropped.Without
preferNoSetFee: true, Keplr overrides the application-provided fee with its own calculation using the chain's native denom. This breaks any app that pays fees in a non-native denomination.Fix
Pass
undefinedinstead of{}for bothsignAminoandsignDirectso the defaults in core are respected.