Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: SwapAmountInput #504

Merged
merged 35 commits into from
Jun 11, 2024
Merged

feat: SwapAmountInput #504

merged 35 commits into from
Jun 11, 2024

Conversation

abcrane123
Copy link
Contributor

@abcrane123 abcrane123 commented Jun 10, 2024

What changed? Why?

  • add SwapAmountInput component

Screenshot 2024-06-10 at 5 42 53 PM

Screenshot 2024-06-10 at 5 42 41 PM

Screenshot 2024-06-10 at 5 43 03 PM

Notes to reviewers
add this back in after PR is merged:

<App>
  <SwapAmountInputContainer>
    {(amount, setAmount, setToken, token, tokenBalance) => (
      <SwapAmountInput
        amount={amount}
        label="Sell"
        setAmount={setAmount}
        setToken={setToken}
        swappableTokens={[
          {
            name: 'Ethereum',
            address: '',
            symbol: 'ETH',
            decimals: 18,
            image: 'https://wallet-api-production.s3.amazonaws.com/uploads/tokens/eth_288.png',
            chainId: 8453,
          },
          {
            name: 'USDC',
            address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
            symbol: 'USDC',
            decimals: 6,
            image:
              'https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/44/2b/442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213-ZWUzYjJmZGUtMDYxNy00NDcyLTg0NjQtMWI4OGEwYjBiODE2',
            chainId: 8453,
          },
          {
            name: 'Dai',
            address: '0x50c5725949a6f0c72e6c4a641f24049a917db0cb',
            symbol: 'DAI',
            decimals: 18,
            image:
              'https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/d0/d7/d0d7784975771dbbac9a22c8c0c12928cc6f658cbcf2bbbf7c909f0fa2426dec-NmU4ZWViMDItOTQyYy00Yjk5LTkzODUtNGJlZmJiMTUxOTgy',
            chainId: 8453,
          },
        ]}
        token={token}
        tokenBalance={tokenBalance}
      />
    )}
  </SwapAmountInputContainer>
</App>

How has it been tested?
locally

@abcrane123 abcrane123 requested review from Zizzamia and kyhyco June 10, 2024 20:42
@abcrane123 abcrane123 marked this pull request as ready for review June 10, 2024 20:42
tokenBalance?: string; // Amount of selected Token user owns
onMaxButtonClick: () => void; // Callback function when max button is clicked
onAmountChange: (amount: string) => void; // Callback function when the amount changes
onTokenSelectorClick: () => void; // Callback function when the token selector is clicked
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's change the onTokenSelectorClick to setToken? The user shouldn't have to know that we are using TokenSelector under the hood.

Suggested change
onTokenSelectorClick: () => void; // Callback function when the token selector is clicked
setToken: () => void; // Callback function when the token selector is clicked

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other cb props i am passing in start with on i.e onAmountChange, onMaxButtonClick. Should I do onTokenSelect to keep it consistent or do you think setToken is more clear ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update: went with setToken and setAmount

src/token/utils.ts Outdated Show resolved Hide resolved

```ts
type SwapAmountInputReact = {
label: string; // Descriptive label for the input field
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep all types alphabetical.

Copy link
Contributor

@Zizzamia Zizzamia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!!!! 👏

@Zizzamia Zizzamia merged commit 3d3ebc7 into main Jun 11, 2024
9 checks passed
@Zizzamia Zizzamia deleted the alissa.crane/swap-amount-input branch June 11, 2024 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants