Sponsored gas toggle#10
Merged
Merged
Conversation
Adds a "Sponsored gas" switch on the wallet page so the connected user can turn Chain.Giving's CGPaymaster sponsorship off for their own transactions. Preference is persisted in localStorage and synced across tabs (storage event) and within the same tab (custom event). When off, useOrgGasSponsorship treats isSponsorshipAvailable as false, so useSponsoredWrite skips wallet_sendCalls + paymasterService and falls back to writeContractAsync — the wallet pays its own gas. The "Create Program (Gas Sponsored)" label flips automatically since it reads the same flag. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reown AppKit's wagmi adapter can surface the chain id in CAIP-2 form
("eip155:84532") on the connector's wallet client. viem later calls
BigInt(chainId) when encoding the tx, which throws SyntaxError. Passing
chainId explicitly to writeContractAsync forces wagmi to resolve the
chain from wagmiConfig instead, sidestepping the adapter's bad value.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Both the initial render state and the post-hydration read now default to false when no preference is stored, so wallets get plain writeContract by default and have to opt in to sponsorship. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reown AppKit's embedded-wallet provider answers eth_chainId with the
CAIP-2 form ("eip155:N"). viem then runs that through hexToNumber →
BigInt(...) and throws SyntaxError, killing any write that hits the
fallback path.
- useSponsoredWrite: drop wagmi's useWriteContract on the non-sponsored
path and call viem.writeContract directly on a wallet client whose
transport proxies eth_chainId responses, rewriting "eip155:N" to a
proper hex chain id. The Chain object is also pinned from wagmiConfig
instead of trusting the connector's chain.
- useTransactor: tolerate walletClient.getChainId() throwing, since
the result is only used to build the block-explorer link.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ReturnType<typeof useWalletClient>["data"] was resolving to {} during
the Next.js build, breaking `raw.account`. Typing the parameter as
viem's WalletClient directly is simpler and resolves cleanly.
Co-Authored-By: Claude Opus 4.7 (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.
No description provided.