Skip to content

Commit

Permalink
Update Connect 1.1.10, and Aptos WA update (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuli-ferna authored Jan 13, 2025
1 parent a4cc328 commit 177e69e
Show file tree
Hide file tree
Showing 10 changed files with 2,093 additions and 4,691 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
name: preview
separator: P
advanced-tools-branch: advanced-tools
advanced-tools-branch: feature/include-scroll-mantle-xlayer
environment: Cloudflare-Preview
public-url: "/${{ needs.branch-sha.outputs.value }}"
wac-url-template: "https://allez-xyz--usds-*.modal.run"
Expand Down
6,677 changes: 2,034 additions & 4,643 deletions apps/connect/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions apps/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
"test:watch": "cross-env VITE_APP_CLUSTER=Mainnet jest --coverage --watchAll=true"
},
"dependencies": {
"@certusone/wormhole-sdk": "^0.10.18",
"@aptos-labs/ts-sdk": "^1.33.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.11",
"@mui/material": "^5.12.1",
"@tanstack/react-query": "^5.14.2",
"@wormhole-foundation/sdk": "^1.0.0",
"@wormhole-foundation/wormhole-connect": "^1.1.9-beta.0-development",
"aptos": "^1.21.0",
"@wormhole-foundation/sdk": "^1.4.0",
"@wormhole-foundation/wormhole-connect": "^1.1.10-beta.2-development",
"bech32": "^2.0.0",
"dompurify": "^3.0.6",
"ethers": "^5.6.8",
"mixpanel-browser": "^2.53.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/connect/src/env/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const MAINNET_RPCS = {
...rpcs(chains, asRpcHost),
Klaytn: "https://public-en.node.kaia.io/",
Solana: "https://wormhole.rpcpool.com/",
Aptos: "https://and76cjzpa.execute-api.us-east-2.amazonaws.com/aptos/v1",
};

export const PUBLIC_URL = envVars.VITE_PUBLIC_URL || "";
Expand All @@ -44,7 +45,6 @@ export const wormholeConnectConfigCommon: Partial<WormholeConnectConfig> = {
title: "",
// cctpWarning: "",
walletConnectProjectId: envVars.VITE_APP_WALLET_CONNECT_PROJECT_ID || "",
showHamburgerMenu: false,
explorer: {
href: `https://wormholescan.io/#/txs?address={:address}&network=${CLUSTER}`,
},
Expand Down
4 changes: 2 additions & 2 deletions apps/connect/src/env/token-bridge.mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ export const ENV: Env = {
Avalanche: "0x137e3b33DC1Fe64bC6FC3d3fF2A801A2fdfcB4b2",
Sui: "0xe817f4f6f07f0da308698a4d9cd8af8a5d05b234edc55ce524916dc8d2b42fa5::coin::COIN",
Aptos:
"0x863d1f83048111cb48be29cf86d2d3da6c48b64e6c60aa72ca3e3f4abe198386",
"0x863d1f83048111cb48be29cf86d2d3da6c48b64e6c60aa72ca3e3f4abe198386::coin::T",
Arbitrum: "0x3Ac2EBFf77Aab7cA87FC0e4e1c1b4a5E219957C2",
Fantom: "0xC07B1b12122e4835e7b3d3920Cd55CA1EB238D6C",
Base: "0x75A078Ab8d977BCECAFAfAAcA4339e6EACf648d3",
Expand All @@ -739,7 +739,7 @@ export const ENV: Env = {
Optimism: "0x5F33522034D2281667b9354D2e9A0317755146AC",
Sui: "0x37f44326b8ffd853e74030a00ede720380d164dcc33949aaf729c675865c4da3::coin::COIN",
Aptos:
"0xb628b3c69a4747cadc570ca75efaf43cff1979db3993d85db7d071a984b9e445",
"0xb628b3c69a4747cadc570ca75efaf43cff1979db3993d85db7d071a984b9e445::coin::T",
Fantom: "0x3f3a9fcAdE548b59E2c335E4f2dF2ae4ed4A6B63",
Base: "0x9e325590933809B3b79B9C892f07D5A89d322542",
Celo: "0xfA9f0D9b7E903970e16f65BD648ddD282E2772a1",
Expand Down
43 changes: 14 additions & 29 deletions apps/connect/src/providers/sanctions.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import {
CHAIN_ID_ALGORAND,
CHAIN_ID_ARBITRUM,
CHAIN_ID_AVAX,
CHAIN_ID_BSC,
CHAIN_ID_BTC,
CHAIN_ID_CELO,
CHAIN_ID_OPTIMISM,
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA,
CHAIN_ID_KLAYTN,
isCosmWasmChain,
isEVMChain,
} from "@certusone/wormhole-sdk";
import { Chain, toChainId } from "@wormhole-foundation/sdk";
import { toChainNameFormat } from "../utils/transferVerification";
import { isCosmWasmChain, isEVMChain } from "../utils/constants";
import { WormholeConnectConfig } from "@wormhole-foundation/wormhole-connect";

export type ExtendedTransferDetails = Parameters<
Expand All @@ -35,23 +21,22 @@ export const RISK_ADDRESS_INDICATOR_TYPE = "OWNERSHIP";
export const getTrmChainName = (chain: Chain) => {
const id = toChainId(chain);
const trmChainNames: any = {
[CHAIN_ID_ALGORAND]: "algorand",
[CHAIN_ID_ARBITRUM]: "arbitrum",
[CHAIN_ID_AVAX]: "avalanche_c_chain",
[CHAIN_ID_BSC]: "binance_smart_chain",
[CHAIN_ID_BTC]: "bitcoin",
[CHAIN_ID_CELO]: "celo",
[CHAIN_ID_KLAYTN]: "klaytn",
[CHAIN_ID_OPTIMISM]: "optimism",
[CHAIN_ID_POLYGON]: "polygon",
[CHAIN_ID_SOLANA]: "solana",
[toChainId("Algorand")]: "algorand",
[toChainId("Arbitrum")]: "arbitrum",
[toChainId("Avalanche")]: "avalanche_c_chain",
[toChainId("Bsc")]: "binance_smart_chain",
[toChainId("Btc")]: "bitcoin",
[toChainId("Celo")]: "celo",
[toChainId("Klaytn")]: "klaytn",
[toChainId("Optimism")]: "optimism",
[toChainId("Polygon")]: "polygon",
[toChainId("Solana")]: "solana",
};

if (trmChainNames[id]) return trmChainNames[id];
if (isCosmWasmChain(toChainNameFormat(chain))) return "cosmos";
if (isCosmWasmChain(chain)) return "cosmos";
// TO DO: Add support for other evm chains with the new sdk
if (isEVMChain(toChainNameFormat(chain)) || chain === "Worldchain")
return "ethereum";
if (isEVMChain(chain) || chain === "Worldchain") return "ethereum";

return "";
};
Expand Down Expand Up @@ -99,7 +84,7 @@ export const isSanctionedAddress = async (
address: transferDetails.toWalletAddress,
}),
...(transferDetails.toChain !== "Ethereum" &&
(isEVMChain(toChainNameFormat(transferDetails.toChain)) ||
(isEVMChain(transferDetails.toChain) ||
transferDetails.toChain === "Worldchain")
? [
isSanctioned({
Expand Down
23 changes: 23 additions & 0 deletions apps/connect/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
import { Chain, platformToChains } from "@wormhole-foundation/sdk";

export const PrivacyPolicyPath = "/privacy-policy";

export const isPreview =
window.location.origin.includes("preview") ||
window.location.origin.includes("testnet");

export const isProduction = window.location.host === "portalbridge.com";

export const CosmWasmChainNames: Chain[] = [
"Terra",
"Terra2",
"Injective",
"Xpla",
"Sei",
"Wormchain",
"Osmosis",
"Evmos",
"Kujira",
] as const;

export const isCosmWasmChain = (chain: Chain) => {
return CosmWasmChainNames.includes(chain);
};

const evmChains = platformToChains("Evm");
export const isEVMChain = (chain: Chain) => {
return evmChains.includes(chain as any);
};
7 changes: 6 additions & 1 deletion apps/connect/src/utils/isValidAddress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ describe("isValidAddress", () => {
"Solana"
)
).toEqual(true);
expect(await isValidAddress("valid", "Aptos")).toEqual(true);
expect(
await isValidAddress(
"0xe13ca6e4f569a54e9fcd330dcf58d8962ed9ebddabaa1221e732da6e7aa212a9",
"Aptos"
)
).toEqual(true);
expect(await isValidAddress("invalid", "Aptos")).toEqual(false);
expect(await isValidAddress("error", "Aptos")).toEqual(false);
});
Expand Down
15 changes: 7 additions & 8 deletions apps/connect/src/utils/isValidAddress.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import base58 from "bs58";
import * as ethers from "ethers";
import { isCosmWasmChain, isEVMChain } from "@certusone/wormhole-sdk";
import { AptosClient } from "aptos";
import { AptosConfig, Aptos, Network } from "@aptos-labs/ts-sdk";
import { bech32 } from "bech32";
import { Chain } from "@wormhole-foundation/sdk";
import { toChainNameFormat } from "./transferVerification";
import { isEVMChain, isCosmWasmChain } from "./constants";

export const isValidAddress = async (
address: string,
chain: Chain
): Promise<boolean> => {
// TO DO: Add support for other evm chains with the new sdk
if (isEVMChain(toChainNameFormat(chain)) || chain === "Worldchain")
if (isEVMChain(chain) || chain === "Worldchain")
return isValidEthereumAddress(address);
if (chain === "Solana") return isValidSolanaAddress(address);
if (chain === "Aptos") return isValidAptosAddress(address);
if (chain === "Sui") return isValidSuiAddress(address);
if (isCosmWasmChain(toChainNameFormat(chain)))
return isValidCosmosAddress(address, chain);
if (isCosmWasmChain(chain)) return isValidCosmosAddress(address, chain);

return false;
};
Expand Down Expand Up @@ -49,10 +47,11 @@ const isValidSolanaAddress = (address: string): boolean => {
};

// Aptos Validation
const aptosClient = new AptosClient("https://api.mainnet.aptoslabs.com/v1");
const config = new AptosConfig({ network: Network.MAINNET });
const aptos = new Aptos(config);
const isValidAptosAddress = async (address: string) => {
try {
return !!(await aptosClient.getAccount(address));
return !!(await aptos.getAccountInfo({ accountAddress: address }));
} catch {
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions apps/connect/src/utils/transferVerification.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { isValidAddress } from "./isValidAddress";
import { isSanctionedAddress } from "../../src/providers/sanctions";
import { ChainName } from "@certusone/wormhole-sdk";
import { Chain } from "@wormhole-foundation/sdk";
import { WormholeConnectConfig } from "@wormhole-foundation/wormhole-connect";

Expand Down Expand Up @@ -34,5 +33,5 @@ export const validateTransfer = async (
};

export const toChainNameFormat = (chain: Chain) => {
return chain.toLowerCase() as ChainName;
return chain.toLowerCase();
};

0 comments on commit 177e69e

Please sign in to comment.