Skip to content

Commit

Permalink
update swap sdk v23 (#1662)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Sinclair <[email protected]>
Co-authored-by: Daniel Sinclair <[email protected]>
  • Loading branch information
3 people authored Aug 16, 2024
1 parent cf5a705 commit 81c79e3
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 127 deletions.
182 changes: 91 additions & 91 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,36 @@ jobs:
- name: Remove old screenshots
run: rm -rf screenshots/*
# FIREFOX TESTS
firefox-e2e-parallel:
runs-on: ubuntu-latest
timeout-minutes: 18
needs: [build]
env:
DISPLAY: :0
VITEST_SEGFAULT_RETRY: 4
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/firefoxTestsSetup
with:
gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
- name: Run e2e parallel (Firefox)
id: FFE2eParallel
continue-on-error: true
run: |
export BROWSER=firefox
export OS=linux
export FIREFOX_BIN="$(pwd)/firefox/firefox"
yarn firefox:manifest && yarn firefox:zip
yarn vitest:parallel
- name: Upload deps artifacts
if: steps.FFE2eParallel.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: screenshots
path: screenshots/
- name: Fail if any tests failed
if: steps.FFE2eParallel.outcome == 'failure'
run: exit 1
# firefox-e2e-parallel:
# runs-on: ubuntu-latest
# timeout-minutes: 18
# needs: [build]
# env:
# DISPLAY: :0
# VITEST_SEGFAULT_RETRY: 4
# steps:
# - uses: actions/checkout@v3
# - uses: ./.github/actions/firefoxTestsSetup
# with:
# gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
# - name: Run e2e parallel (Firefox)
# id: FFE2eParallel
# continue-on-error: true
# run: |
# export BROWSER=firefox
# export OS=linux
# export FIREFOX_BIN="$(pwd)/firefox/firefox"
# yarn firefox:manifest && yarn firefox:zip
# yarn vitest:parallel
# - name: Upload deps artifacts
# if: steps.FFE2eParallel.outcome == 'failure'
# uses: actions/upload-artifact@v3
# with:
# name: screenshots
# path: screenshots/
# - name: Fail if any tests failed
# if: steps.FFE2eParallel.outcome == 'failure'
# run: exit 1
# firefox-e2e-swap:
# runs-on: swaps-runner-bx
# timeout-minutes: 25
Expand Down Expand Up @@ -130,66 +130,66 @@ jobs:
# - name: Fail if any tests failed
# if: steps.FFE2eSwap.outcome == 'failure'
# run: exit 1
firefox-e2e-send:
runs-on: send-runner-bx
timeout-minutes: 16
needs: [build]
env:
DISPLAY: :0
VITEST_SEGFAULT_RETRY: 4
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/firefoxTestsSetup
with:
gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
- name: Run e2e Send (Firefox)
id: FFE2eSend
continue-on-error: true
run: |
export BROWSER=firefox
export OS=linux
export FIREFOX_BIN="$(pwd)/firefox/firefox"
yarn firefox:manifest && yarn firefox:zip
yarn vitest:send
- name: Upload deps artifacts
if: steps.FFE2eSend.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: screenshots
path: screenshots/
- name: Fail if any tests failed
if: steps.FFE2eSend.outcome == 'failure'
run: exit 1
firefox-e2e-dappInteractions:
runs-on: dapp-interactions-runner-bx
timeout-minutes: 25
needs: [build]
env:
DISPLAY: :0
VITEST_SEGFAULT_RETRY: 4
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/firefoxTestsSetup
with:
gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
- name: Run e2e Dapp Interactions (Firefox)
id: FFE2eDappInteractions
continue-on-error: true
run: |
export BROWSER=firefox
export OS=linux
export FIREFOX_BIN="$(pwd)/firefox/firefox"
yarn firefox:manifest && yarn firefox:zip
yarn vitest:dappInteractions
- name: Upload deps artifacts
if: steps.FFE2eDappInteractions.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: screenshots
path: screenshots/
- name: Fail if any tests failed
if: steps.FFE2eDappInteractions.outcome == 'failure'
run: exit 1
# firefox-e2e-send:
# runs-on: send-runner-bx
# timeout-minutes: 16
# needs: [build]
# env:
# DISPLAY: :0
# VITEST_SEGFAULT_RETRY: 4
# steps:
# - uses: actions/checkout@v3
# - uses: ./.github/actions/firefoxTestsSetup
# with:
# gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
# - name: Run e2e Send (Firefox)
# id: FFE2eSend
# continue-on-error: true
# run: |
# export BROWSER=firefox
# export OS=linux
# export FIREFOX_BIN="$(pwd)/firefox/firefox"
# yarn firefox:manifest && yarn firefox:zip
# yarn vitest:send
# - name: Upload deps artifacts
# if: steps.FFE2eSend.outcome == 'failure'
# uses: actions/upload-artifact@v3
# with:
# name: screenshots
# path: screenshots/
# - name: Fail if any tests failed
# if: steps.FFE2eSend.outcome == 'failure'
# run: exit 1
# firefox-e2e-dappInteractions:
# runs-on: dapp-interactions-runner-bx
# timeout-minutes: 25
# needs: [build]
# env:
# DISPLAY: :0
# VITEST_SEGFAULT_RETRY: 4
# steps:
# - uses: actions/checkout@v3
# - uses: ./.github/actions/firefoxTestsSetup
# with:
# gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
# - name: Run e2e Dapp Interactions (Firefox)
# id: FFE2eDappInteractions
# continue-on-error: true
# run: |
# export BROWSER=firefox
# export OS=linux
# export FIREFOX_BIN="$(pwd)/firefox/firefox"
# yarn firefox:manifest && yarn firefox:zip
# yarn vitest:dappInteractions
# - name: Upload deps artifacts
# if: steps.FFE2eDappInteractions.outcome == 'failure'
# uses: actions/upload-artifact@v3
# with:
# name: screenshots
# path: screenshots/
# - name: Fail if any tests failed
# if: steps.FFE2eDappInteractions.outcome == 'failure'
# run: exit 1
# CHROME TESTS
chrome-e2e-parallel:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -457,7 +457,7 @@ jobs:
run: yarn typecheck
cleanup:
runs-on: ubuntu-latest
needs: [firefox-e2e-parallel, firefox-e2e-send, firefox-e2e-dappInteractions, chrome-e2e-parallel, chrome-e2e-swap, chrome-e2e-send, chrome-e2e-dappInteractions, chrome-optimism-e2e-send, unit-tests, ci-checks]
needs: [chrome-e2e-parallel, chrome-e2e-swap, chrome-e2e-send, chrome-e2e-dappInteractions, chrome-optimism-e2e-send, unit-tests, ci-checks]
steps:
- uses: geekyeggo/delete-artifact@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"@radix-ui/react-tabs": "1.0.4",
"@radix-ui/react-tooltip": "1.0.3",
"@rainbow-me/provider": "0.1.1",
"@rainbow-me/swaps": "0.21.0",
"@rainbow-me/swaps": "0.23.0",
"@rudderstack/analytics-js-service-worker": "3.0.6",
"@scure/bip39": "1.2.1",
"@sentry/browser": "8.15.0",
Expand Down Expand Up @@ -328,4 +328,4 @@
"wagmi>@wagmi/connectors>@metamask/sdk>eciesjs>secp256k1": false
}
}
}
}
4 changes: 3 additions & 1 deletion src/core/raps/actions/claimBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Address } from 'viem';
import { optimism } from 'viem/chains';

import { REFERRER_CLAIM } from '~/core/references';
import { gasStore } from '~/core/state';
import { currentCurrencyStore, gasStore } from '~/core/state';
import { TransactionGasParams } from '~/core/types/gas';
import { NewTransaction, TxHash } from '~/core/types/transactions';
import { calculateL1FeeOptimism } from '~/core/utils/gas';
Expand Down Expand Up @@ -55,6 +55,7 @@ export async function claimBridge({
sellAmount: sellAmount,
slippage: 2,
swapType: SwapType.crossChain,
currency: currentCurrencyStore.getState().currentCurrency,
});

// if we don't get a quote or there's an error we can't continue
Expand Down Expand Up @@ -122,6 +123,7 @@ export async function claimBridge({
sellAmount: maxBridgeableAmount,
slippage: 2,
swapType: SwapType.crossChain,
currency: currentCurrencyStore.getState().currentCurrency,
});

if (!newQuote || (newQuote as QuoteError)?.error) {
Expand Down
1 change: 1 addition & 0 deletions src/core/raps/actions/crosschainSwap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ beforeAll(async () => {
destReceiver: TEST_ADDRESS_3,
swapType: SwapType.crossChain,
toChainId: ChainId.arbitrum,
currency: 'USD',
});
}, 20000);

Expand Down
1 change: 1 addition & 0 deletions src/core/raps/actions/swap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ beforeAll(async () => {
destReceiver: TEST_ADDRESS_2,
swapType: SwapType.normal,
toChainId: 1,
currency: 'USD',
});
}, 10000);

Expand Down
15 changes: 14 additions & 1 deletion src/core/raps/unlockAndCrosschainSwap.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { CrosschainQuote, Quote, QuoteError } from '@rainbow-me/swaps';
import {
CrosschainQuote,
Quote,
QuoteError,
TokenAsset,
} from '@rainbow-me/swaps';
import { mainnet } from 'viem/chains';
import { beforeAll, expect, test } from 'vitest';

Expand All @@ -24,6 +29,7 @@ const needsUnlockQuote: Quote | QuoteError | null = {
chainId: 1,
buyAmount: '22815411',
buyAmountDisplay: '22815411',
buyAmountDisplayMinimum: '22815411',
buyAmountInEth: '7674057708816777',
buyAmountMinusFees: '7674057708816777',
buyTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
Expand All @@ -48,12 +54,16 @@ const needsUnlockQuote: Quote | QuoteError | null = {
to: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
tradeAmountUSD: 21.84463710898238,
value: '0',
buyTokenAsset: {} as TokenAsset, // not used in this test
feeTokenAsset: {} as TokenAsset, // not used in this test
sellTokenAsset: {} as TokenAsset, // not used in this test
};

const doesntNeedUnlockQuote: Quote | QuoteError | null = {
chainId: 1,
buyAmount: '2934529154',
buyAmountDisplay: '2934529154',
buyAmountDisplayMinimum: '2934529154',
buyAmountInEth: '988585673036047522',
buyAmountMinusFees: '988585673036047522',
buyTokenAddress: '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8',
Expand Down Expand Up @@ -82,6 +92,9 @@ const doesntNeedUnlockQuote: Quote | QuoteError | null = {
to: TEST_ADDRESS_2,
tradeAmountUSD: 2963.84,
value: '0x0de0b6b3a7640000',
buyTokenAsset: {} as TokenAsset, // not used in this test
feeTokenAsset: {} as TokenAsset, // not used in this test
sellTokenAsset: {} as TokenAsset, // not used in this test
};

beforeAll(async () => {
Expand Down
5 changes: 5 additions & 0 deletions src/core/raps/unlockAndSwap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ beforeAll(async () => {
destReceiver: TEST_ADDRESS_2,
swapType: SwapType.normal,
toChainId: 1,
currency: 'USD',
});
ethToEnsQuote = await getQuote({
chainId: 1,
Expand All @@ -83,6 +84,7 @@ beforeAll(async () => {
destReceiver: TEST_ADDRESS_2,
swapType: SwapType.normal,
toChainId: 1,
currency: 'USD',
});
needsUnlockQuote = await getQuote({
chainId: 1,
Expand All @@ -94,6 +96,7 @@ beforeAll(async () => {
destReceiver: TEST_ADDRESS_2,
swapType: SwapType.normal,
toChainId: 1,
currency: 'USD',
});
wrapEthQuote = await getQuote({
chainId: 1,
Expand All @@ -105,6 +108,7 @@ beforeAll(async () => {
destReceiver: TEST_ADDRESS_2,
swapType: SwapType.normal,
toChainId: 1,
currency: 'USD',
});
unwrapEthQuote = await getQuote({
chainId: 1,
Expand All @@ -116,6 +120,7 @@ beforeAll(async () => {
destReceiver: TEST_ADDRESS_2,
swapType: SwapType.normal,
toChainId: 1,
currency: 'USD',
});
}, 10000);

Expand Down
Loading

0 comments on commit 81c79e3

Please sign in to comment.