forked from 0xsequence/web-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
# Sequence diagram for updated crypto checkout balance and swap checks #242
Copy link
Copy link
Open
Labels
dependenciesPull requests that update a dependency filePull requests that update a dependency filedocumentationImprovements or additions to documentationImprovements or additions to documentationduplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersinvalidThis doesn't seem rightThis doesn't seem rightjavascriptPull requests that update javascript codePull requests that update javascript codequestionFurther information is requestedFurther information is requested
Metadata
Metadata
Assignees
Labels
dependenciesPull requests that update a dependency filePull requests that update a dependency filedocumentationImprovements or additions to documentationImprovements or additions to documentationduplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersinvalidThis doesn't seem rightThis doesn't seem rightjavascriptPull requests that update javascript codePull requests that update javascript codequestionFurther information is requestedFurther information is requested
Projects
Status
Backlog
Status
Todo
Reviewer's Guide
Bumps the Sequence Web SDK packages from 5.4.3 to 5.4.8 with corresponding sequence.js dependency/peer updates, adjusts swap route/quote and linked-wallet hooks to the latest API request types and parameter shapes, fixes checkout free-item and insufficient-balance logic using BigInt, updates Sequence logo coloring to use CSS variables, and tweaks workspace release configuration.
Sequence diagram for updated crypto checkout balance and swap checks
sequenceDiagram actor User participant PayWithCryptoTab participant useInitialBalanceCheck participant useGetSwapRoutes participant SequenceAPIClient User->>PayWithCryptoTab: Open crypto payment tab PayWithCryptoTab->>PayWithCryptoTab: Compute price PayWithCryptoTab->>PayWithCryptoTab: isFree = BigInt(price) === 0n PayWithCryptoTab->>PayWithCryptoTab: userBalance = BigInt(tokenBalance.balance || '0') PayWithCryptoTab->>PayWithCryptoTab: requiredBalance = BigInt(selectedCurrencyPrice) PayWithCryptoTab->>PayWithCryptoTab: isInsufficientBalance = !isFree && userBalance < requiredBalance PayWithCryptoTab->>useInitialBalanceCheck: useInitialBalanceCheck({ userAddress, buyCurrencyAddress, price, chainId, isInsufficientBalance, tokenBalancesIsLoading }) useInitialBalanceCheck->>useInitialBalanceCheck: isFree = BigInt(price) === 0n alt Free item (isFree === true) useInitialBalanceCheck->>useInitialBalanceCheck: Disable initial balance and swap route checks else Paid item and insufficient balance useInitialBalanceCheck->>useInitialBalanceCheck: Trigger insufficient balance check query useInitialBalanceCheck->>useGetSwapRoutes: useGetSwapRoutes({ chainId, walletAddress, toTokenAddress, toTokenAmount }) useGetSwapRoutes->>SequenceAPIClient: getLifiSwapRoutes({ params: { direction, chainId, walletAddress, tokenAddress, tokenAmount } }) SequenceAPIClient-->>useGetSwapRoutes: routes useGetSwapRoutes-->>useInitialBalanceCheck: swap routes result end useInitialBalanceCheck-->>PayWithCryptoTab: Update navigation params.isInitialBalanceChecked PayWithCryptoTab-->>User: Show pay, top-up, or swap options based on balance and routesClass diagram for updated swap, quote, and linked-wallet hooks
classDiagram class SequenceAPIClient { +getLifiSwapRoutes(request GetLifiSwapRoutesRequest) Promise~GetLifiSwapRoutesResponse~ +getLifiSwapQuote(request GetLifiSwapQuoteRequest) Promise~GetLifiSwapQuoteResponse~ +getLinkedWallets(request GetLinkedWalletsRequest, headers object, signal AbortSignal) Promise~LinkedWallet[]~ } class GetSwapRoutesArgs { +number chainId +string walletAddress +string toTokenAddress +string toTokenAmount } class UseGetSwapRoutesArgs { +number chainId +string walletAddress +string toTokenAddress +string toTokenAmount } class LifiSwapRoute { +string id +string fromToken +string toToken +string toAmount } class GetLifiSwapRoutesRequest { +GetLifiSwapRouteDirection direction +number chainId +string walletAddress +string tokenAddress +string tokenAmount } class GetLifiSwapRoutesResponse { +LifiSwapRoute[] routes } class GetLifiSwapQuoteRequest { +number chainId +string fromTokenAddress +string toTokenAddress +string fromTokenAmount +string walletAddress } class GetLifiSwapQuoteResponse { +string estimatedToTokenAmount +string feeAmount } class LinkedWallet { +string walletAddress +number chainId } class GetLinkedWalletsRequest { +string parentWalletAddress +number signatureChainId } class useGetSwapRoutesHook { +useGetSwapRoutes(args UseGetSwapRoutesArgs, options HooksOptions) QueryResult~LifiSwapRoute[]~ } class useGetSwapQuoteHook { +useGetSwapQuote(args GetLifiSwapQuoteRequest, options HooksOptions) QueryResult~GetLifiSwapQuoteResponse~ } class useLinkedWalletsHook { +useLinkedWallets(args GetLinkedWalletsRequest, options UseLinkedWalletsOptions) UseLinkedWalletsResult } SequenceAPIClient --> GetLifiSwapRoutesRequest SequenceAPIClient --> GetLifiSwapRoutesResponse SequenceAPIClient --> GetLifiSwapQuoteRequest SequenceAPIClient --> GetLifiSwapQuoteResponse SequenceAPIClient --> GetLinkedWalletsRequest SequenceAPIClient --> LinkedWallet useGetSwapRoutesHook --> SequenceAPIClient useGetSwapRoutesHook --> UseGetSwapRoutesArgs UseGetSwapRoutesArgs --> GetSwapRoutesArgs useGetSwapQuoteHook --> SequenceAPIClient useGetSwapQuoteHook --> GetLifiSwapQuoteRequest useLinkedWalletsHook --> SequenceAPIClient useLinkedWalletsHook --> GetLinkedWalletsRequest useLinkedWalletsHook --> LinkedWalletClass diagram for connect exports including new metaMask connector
classDiagram class ConnectIndex { +sequence(options SequenceOptions) Connector +twitch(options TwitchOptions) Connector +walletConnect(options WalletConnectOptions) Connector +ecosystemWallet(options EcosystemWalletOptions) Connector +sequenceWaasWallet(options SequenceWaasWalletOptions) Connector +mock() Connector +metaMask() Connector } class metaMaskConnector { +metaMask() Connector } class sequenceConnector { +sequence(options SequenceOptions) Connector } class walletConnectConnector { +walletConnect(options WalletConnectOptions) Connector } class twitchConnector { +twitch(options TwitchOptions) Connector } class ecosystemWalletConnector { +ecosystemWallet(options EcosystemWalletOptions) Connector } class sequenceWaasWalletConnector { +sequenceWaasWallet(options SequenceWaasWalletOptions) Connector } class mockConnector { +mock() Connector } ConnectIndex --> metaMaskConnector ConnectIndex --> sequenceConnector ConnectIndex --> walletConnectConnector ConnectIndex --> twitchConnector ConnectIndex --> ecosystemWalletConnector ConnectIndex --> sequenceWaasWalletConnector ConnectIndex --> mockConnectorFile-Level Changes
packages/connect/package.jsonpackages/hooks/package.jsonpackages/checkout/package.jsonpackages/wallet-widget/package.jsonpackages/immutable-connector/package.jsonexamples/next/package.jsonexamples/react/package.jsonpackages/wallet-widget/CHANGELOG.mdpackages/checkout/CHANGELOG.mdpackages/connect/CHANGELOG.mdpackages/immutable-connector/CHANGELOG.mdpackages/hooks/CHANGELOG.mdpackages/connect/src/constants/version.tspnpm-lock.yamlpackages/hooks/src/hooks/Combination/useGetSwapRoutes.tspackages/hooks/src/hooks/Combination/useGetSwapQuote.tspackages/connect/src/hooks/useWallets.tspackages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/index.tsxpackages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/useInitialBalanceCheck.tsxpackages/connect/src/connectors/sequence/SequenceLogo.tsxpackages/wallet-widget/src/components/ConnectorLogos/SequenceLogo.tsxpackages/connect/src/index.tspnpm-workspace.yamlTips and commands
Interacting with Sourcery
@sourcery-ai reviewon the pull request.issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it.@sourcery-aianywhere in the pullrequest title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time.@sourcery-ai summaryanywhere inthe pull request body to generate a PR summary at any time exactly where you
want it. You can also comment
@sourcery-ai summaryon the pull request to(re-)generate the summary at any time.
@sourcery-ai guideon the pullrequest to (re-)generate the reviewer's guide at any time.
@sourcery-ai resolveon thepull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
@sourcery-ai dismisson the pullrequest to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!Customizing Your Experience
Access your dashboard to:
summary, the reviewer's guide, and others.
Getting Help
Originally posted by @sourcery-ai[bot] in #241 (comment)