feat(core): adapter capabilities, signerAddress & fetchAccount#97
Open
Sanka-D wants to merge 1 commit into
Open
feat(core): adapter capabilities, signerAddress & fetchAccount#97Sanka-D wants to merge 1 commit into
Sanka-D wants to merge 1 commit into
Conversation
…count
Brings three SEP-43-inspired additions xrpl-connect lacked vs Stellar Wallets
Kit, all backward compatible:
- Capabilities: WalletAdapter.capabilities ({ sign, signAndSubmit, signMessage })
+ WalletManager.supports(capability). Operations an adapter declares
unsupported throw a typed UNSUPPORTED_METHOD before the adapter is called,
instead of failing deep inside a stub. Xaman and WalletConnect declare
signMessage: false. Undeclared flags default to true (adapterSupports /
CAPABILITY_DEFAULTS), so existing adapters are unaffected.
- signerAddress: added to SignedTransaction/SignedMessage; the manager stamps
the connected account when the adapter omits it, so callers always know which
account signed.
- fetchAccount(): live re-fetch of the account (vs the cached `account` getter),
emitting accountChanged on difference. ConnectOptions.skipRequestAccess is now
a documented first-class option.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1/4 of closing the feature gap surfaced by comparing xrpl-connect with Stellar Wallets Kit. All additive & backward compatible.
What & why
1. Declarative adapter capabilities (gap #4)
Some adapters expose signing methods that don't actually work —
signMessageis a stub on Xaman (returns an empty signature) and throwsUNSUPPORTED_METHODon WalletConnect. Consumers only discovered this at call time.WalletAdapter.capabilities?: WalletCapabilities({ sign?, signAndSubmit?, signMessage? }).WalletManager.supports(capability)→ tells apps up-front what the connected wallet can do (e.g. hide a "Sign message" button).UNSUPPORTED_METHODbefore invoking an adapter that declares the op unsupported.signMessage: false.true(adapterSupports()/CAPABILITY_DEFAULTS), so every existing adapter keeps working unchanged.Mirrors SWK's per-module capability gating (
signAndSubmitTransaction?optional + clear "not supported" error).2.
signerAddresson sign results (gap #7)SignedTransaction/SignedMessagegainsignerAddress. The manager stamps it with the connected account when the adapter omits it, so callers always know which account produced a signature (matters for multi-account / hardware). Never overwrites a value the adapter already set.3.
fetchAccount()+skipRequestAccess(gap #8)WalletManager.fetchAccount()— live re-fetch from the wallet + refresh the cachedaccount, emittingaccountChangedon difference. This is SWK'sgetAddress(cached) vsfetchAddress(live) distinction, which we only had half of.ConnectOptions.skipRequestAccess— now a documented first-class option (SEP-43 parity); adapters may honour it.Changes
packages/core/src/types.ts—WalletCapabilities,adapterSupports,CAPABILITY_DEFAULTS,capabilitiesonWalletAdapter,signerAddresson sign results,skipRequestAccessonConnectOptions.packages/core/src/wallet-manager.ts— capability gating,signerAddressstamping,supports(),fetchAccount().packages/core/src/index.ts— exports.packages/adapters/{xaman,walletconnect}— declaresignMessage: false.packages/core/tests/wallet-manager.test.ts— +7 tests.Verification
pnpm build(full workspace, 13/13) ✅pnpm test— core 20 passed (+7), xaman 8, walletconnect 10 ✅pnpm lint✅ ·prettier --check✅🤖 Generated with Claude Code