Skip to content

Commit

Permalink
Merge branch 'stage' into jon/fe-612-mobile-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
jonator committed Jul 8, 2024
2 parents 9784866 + b28f8b8 commit e94b219
Show file tree
Hide file tree
Showing 143 changed files with 1,515 additions and 3,757 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/frontend-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: |
echo "$GITHUB_OUTPUT"
yarn --cwd packages/web install --frozen-lockfile && npx playwright install --with-deps chromium
- name: Run Swap Pair tests on Stage
- name: Run Swap Pair tests
env:
BASE_URL: "https://${{ needs.wait-for-deployment.outputs.environment_url }}"
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Install Playwright
run: |
yarn --cwd packages/web install --frozen-lockfile && npx playwright install --with-deps chromium
- name: Run Portfolio tests on Stage
- name: Run Portfolio tests
env:
BASE_URL: "https://${{ needs.wait-for-deployment.outputs.environment_url }}"
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
Expand All @@ -108,3 +108,38 @@ jobs:
with:
name: preview-portfolio-test-results
path: packages/web/playwright-report

preview-pools-tests:
needs: wait-for-deployment
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache dependencies
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.OS }}-20.x-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-20.x-
- name: Install Playwright
run: |
yarn --cwd packages/web install --frozen-lockfile && npx playwright install --with-deps chromium
- name: Run Pools tests
env:
BASE_URL: "https://${{ needs.wait-for-deployment.outputs.environment_url }}"
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
run: |
cd packages/web
npx playwright test -g "Test Select Pool feature"
- name: upload pools test results
if: always()
id: pools-test-results
uses: actions/upload-artifact@v4
with:
name: preview-pools-test-results
path: packages/web/playwright-report
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ src/styles/index.scss
lerna-debug.log
coverage

tsconfig.tsbuildinfo
tsconfig.tsbuildinfo
packages/web/e2e/keplr-extension-manifest
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ describe("SkipBridgeProvider", () => {
toChain
);

expect(addressList).toEqual([fromAddress]);
expect(addressList).toEqual([fromAddress, toAddress]);
});

it("should return correct finality time for known chain IDs", () => {
Expand Down
27 changes: 20 additions & 7 deletions packages/bridge/src/skip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,28 +559,41 @@ export class SkipBridgeProvider implements BridgeProvider {
throw new Error(`Failed to find chain ${chainID}`);
}

if (chain.chain_type === "evm" && fromChain.chainType === "evm") {
if (
chain.chain_type === "evm" &&
chain.chain_id === String(fromChain.chainId) &&
fromChain.chainType === "evm"
) {
addressList.push(fromAddress);
continue;
}

if (chain.chain_type === "evm" && toChain.chainType === "evm") {
if (
chain.chain_type === "evm" &&
chain.chain_id === String(toChain.chainId) &&
toChain.chainType === "evm"
) {
addressList.push(toAddress);
continue;
}

if (chain.chain_type === "cosmos" && fromChain.chainType === "cosmos") {
if (
chain.chain_type === "cosmos" &&
chain.chain_id === String(fromChain.chainId) &&
fromChain.chainType === "cosmos"
) {
addressList.push(
toBech32(chain.bech32_prefix, fromBech32(fromAddress).data)
);
continue;
}

if (chain.chain_type === "cosmos" && toChain.chainType === "cosmos") {
if (
chain.chain_type === "cosmos" &&
chain.chain_id === String(toChain.chainId) &&
toChain.chainType === "cosmos"
) {
addressList.push(
toBech32(chain.bech32_prefix, fromBech32(toAddress).data)
);
continue;
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@keplr-wallet/unit": "0.10.24-ibc.go.v7.hot.fix",
"@osmosis-labs/types": "^1.0.0",
"sha.js": "^2.4.11",
"viem": "2.16.4"
"viem": "2.16.4",
"@cosmjs/encoding": "0.32.3"
},
"devDependencies": {
"@types/jest-in-case": "^1.0.6",
Expand Down
25 changes: 25 additions & 0 deletions packages/utils/src/string.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import * as cosmjsEncoding from "@cosmjs/encoding";
import * as viem from "viem";

/** Trucates a string with ellipsis, default breakpoint: `num = 8`. */
export function truncateString(str: string, num = 8) {
if (str.length <= num) {
Expand Down Expand Up @@ -58,3 +61,25 @@ export const ellipsisText = (str: string, maxLength: number): string => {
export const camelCaseToSnakeCase = (input: string) => {
return input.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
};

export function isEvmAddressValid({ address }: { address: string }): boolean {
return viem.isAddress(address);
}

export function isCosmosAddressValid({
address,
bech32Prefix,
}: {
address: string;
bech32Prefix: string;
}): boolean {
try {
const { prefix, data } = cosmjsEncoding.fromBech32(address);
if (prefix !== bech32Prefix) {
return false;
}
return data.length === 20;
} catch {
return false;
}
}
2 changes: 1 addition & 1 deletion packages/web/components/alloyed-assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const AlloyedAssetsSection = (props: AlloyedAssetsSectionProps) => {
}

return (
<section>
<section className={className}>
<h3 className="mb-8 text-h6 font-semibold">
{t("tokenInfos.underlyingAssets.title")}
</h3>
Expand Down
12 changes: 10 additions & 2 deletions packages/web/components/bridge/amount-and-review-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const AmountAndReviewScreen = observer(
const [cryptoAmount, setCryptoAmount] = useState<string>("0");
const [fiatAmount, setFiatAmount] = useState<string>("0");

const [manualToAddress, setManualToAddress] = useState<string>();

// Wallets
const { address: evmAddress, connector: evmConnector } =
useEvmWalletAccount();
Expand All @@ -59,8 +61,11 @@ export const AmountAndReviewScreen = observer(
fromChain?.chainType === "evm"
? evmAddress
: fromChainCosmosAccount?.address;
const toAddress =
toChain?.chainType === "evm" ? evmAddress : toChainCosmosAccount?.address;
const toAddress = !isNil(manualToAddress)
? manualToAddress
: toChain?.chainType === "evm"
? evmAddress
: toChainCosmosAccount?.address;

const fromWalletIcon =
fromChain?.chainType === "evm"
Expand Down Expand Up @@ -129,6 +134,8 @@ export const AmountAndReviewScreen = observer(
setFromChain={setFromChain}
toChain={toChain}
setToChain={setToChain}
manualToAddress={manualToAddress}
setManualToAddress={setManualToAddress}
fromAsset={fromAsset}
setFromAsset={setFromAsset}
toAsset={toAsset}
Expand Down Expand Up @@ -169,6 +176,7 @@ export const AmountAndReviewScreen = observer(
onConfirm={() => {
quote.onTransfer().catch(noop);
}}
isManualAddress={!isNil(manualToAddress)}
/>
)}
</>
Expand Down
Loading

0 comments on commit e94b219

Please sign in to comment.