fix(hooks): thread network through escrow, subscription, and payment-… - #63
Open
AbuJulaybeeb wants to merge 3 commits into
Open
fix(hooks): thread network through escrow, subscription, and payment-…#63AbuJulaybeeb wants to merge 3 commits into
AbuJulaybeeb wants to merge 3 commits into
Conversation
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.
Summary
network(testnet|mainnet) through Escrow, Subscription, and Payment Request React Query cache keys and API calls.escrowKeys,subscriptionKeys, andpaymentRequestKeyshelpers to includenetworkin list and detail query keys.escrowApi,subscriptionApi, andpaymentRequestApiinsrc/lib/api.tsto acceptnetwork?: Networkand include it in requestparamsor payload bodies.CreateEscrowRequest,CreateSubscriptionRequest, andCreatePaymentRequestPayloadtypes insrc/types/index.tsto include optionalnetwork?: Network.src/hooks/networkAwareness.test.tsandsrc/lib/api.test.tsverifying network-scoped query key generation and API parameter forwarding.CHANGELOG.md.Why
Unlike transaction history hooks (which already threaded
networkthrough both React Query keys and Horizon API calls), the Escrow, Subscription, and Payment Request hooks were not readingnetworkfromuseWallet(). This caused two critical issues:Implementation
network?: NetworktoCreateEscrowRequest,CreateSubscriptionRequest, andCreatePaymentRequestPayload.subscriptionApi,paymentRequestApi, andescrowApimethods (list,get,build*,create,release,refund,cancel) to forwardnetworkin request parameters and data.useEscrowList,useCreateEscrow,useReleaseEscrow,useRefundEscrow,useSubscriptionList,useCreateSubscription,useCancelSubscription,usePaymentRequestList,usePaymentRequest,useCreatePaymentRequest, anduseCancelPaymentRequestto destructurenetworkfromuseWallet()and pass it into cache keys and API calls.params: { publicKey, network }.Testing
npm run test(Vitest test suite includingnetworkAwareness.test.tsandapi.test.ts)['escrows', 'list', pubKey, 'testnet']vs['escrows', 'list', pubKey, 'mainnet']escrowApi.list(pubKey, 'testnet')sends{ publicKey: pubKey, network: 'testnet' }.Scope / Risk
src/types/index.ts,src/lib/api.ts,src/hooks/useEscrows.ts,src/hooks/useSubscriptions.ts,src/hooks/usePaymentRequests.ts,CHANGELOG.md.Issue
closes #59