bridge_ui: add Aurora to testnet

This commit is contained in:
Evan Gray 2022-03-16 20:43:32 -04:00 committed by Evan Gray
parent ca0b9cd35c
commit 32634f87e6
8 changed files with 157 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import {
CHAIN_ID_AURORA,
CHAIN_ID_AVAX,
CHAIN_ID_BSC,
CHAIN_ID_ETH,
@ -342,6 +343,17 @@ export default function NFTOriginVerifier() {
>
View on Snowtrace
</Button>
) : originInfo.chainId === CHAIN_ID_AURORA ? (
<Button
href={`https://aurorascan.dev/token/${readableAddress}?a=${originInfo.tokenId}`}
target="_blank"
rel="noopener noreferrer"
startIcon={<Launch />}
className={classes.viewButton}
variant="outlined"
>
View on Explorer
</Button>
) : originInfo.chainId === CHAIN_ID_FANTOM ? (
<Button
href={`https://ftmscan.com/token/${readableAddress}?a=${originInfo.tokenId}`}

View File

@ -1,5 +1,6 @@
import {
ChainId,
CHAIN_ID_AURORA,
CHAIN_ID_AVAX,
CHAIN_ID_BSC,
CHAIN_ID_ETH,
@ -62,6 +63,10 @@ export default function ShowTx({
? `https://${
CLUSTER === "testnet" ? "testnet." : ""
}explorer.emerald.oasis.dev/tx/${tx?.id}`
: chainId === CHAIN_ID_AURORA
? `https://${CLUSTER === "testnet" ? "testnet." : ""}aurorascan.dev/tx/${
tx?.id
}`
: chainId === CHAIN_ID_FANTOM
? `https://${CLUSTER === "testnet" ? "testnet." : ""}ftmscan.com/tx/${
tx?.id

View File

@ -1,5 +1,6 @@
import {
ChainId,
CHAIN_ID_AURORA,
CHAIN_ID_AVAX,
CHAIN_ID_BSC,
CHAIN_ID_ETH,
@ -121,6 +122,10 @@ export default function SmartAddress({
? `https://${
CLUSTER === "testnet" ? "testnet." : ""
}explorer.emerald.oasis.dev/address/${useableAddress}`
: chainId === CHAIN_ID_AURORA
? `https://${
CLUSTER === "testnet" ? "testnet." : ""
}aurorascan.dev/address/${useableAddress}`
: chainId === CHAIN_ID_FANTOM
? `https://${
CLUSTER === "testnet" ? "testnet." : ""

View File

@ -1,5 +1,6 @@
import {
ChainId,
CHAIN_ID_AURORA,
CHAIN_ID_FANTOM,
CHAIN_ID_OASIS,
CHAIN_ID_POLYGON,
@ -75,7 +76,9 @@ export default function TransactionProgress({
const expectedBlocks =
chainId === CHAIN_ID_POLYGON
? 512 // minimum confirmations enforced by guardians
: chainId === CHAIN_ID_FANTOM || chainId === CHAIN_ID_OASIS
: chainId === CHAIN_ID_OASIS ||
chainId === CHAIN_ID_AURORA ||
chainId === CHAIN_ID_FANTOM
? 1 // these chains only require 1 conf
: chainId === CHAIN_ID_SOLANA
? 32

View File

@ -1,4 +1,5 @@
import {
CHAIN_ID_AURORA,
CHAIN_ID_AVAX,
CHAIN_ID_BSC,
CHAIN_ID_ETH,
@ -35,6 +36,7 @@ import {
WAVAX_ADDRESS,
WBNB_ADDRESS,
WETH_ADDRESS,
WETH_AURORA_ADDRESS,
WFTM_ADDRESS,
WMATIC_ADDRESS,
WROSE_ADDRESS,
@ -92,6 +94,10 @@ function Redeem() {
targetChain === CHAIN_ID_OASIS &&
targetAsset &&
targetAsset.toLowerCase() === WROSE_ADDRESS.toLowerCase();
const isAuroraNative =
targetChain === CHAIN_ID_AURORA &&
targetAsset &&
targetAsset.toLowerCase() === WETH_AURORA_ADDRESS.toLowerCase();
const isFantomNative =
targetChain === CHAIN_ID_FANTOM &&
targetAsset &&
@ -107,6 +113,7 @@ function Redeem() {
isPolygonNative ||
isAvaxNative ||
isOasisNative ||
isAuroraNative ||
isFantomNative ||
isSolNative;
const [useNativeRedeem, setUseNativeRedeem] = useState(true);

View File

@ -1,5 +1,6 @@
import {
ChainId,
CHAIN_ID_AURORA,
CHAIN_ID_AVAX,
CHAIN_ID_BSC,
CHAIN_ID_ETH,
@ -75,6 +76,8 @@ import {
WBNB_ADDRESS,
WBNB_DECIMALS,
WETH_ADDRESS,
WETH_AURORA_ADDRESS,
WETH_AURORA_DECIMALS,
WETH_DECIMALS,
WFTM_ADDRESS,
WFTM_DECIMALS,
@ -348,6 +351,29 @@ const createNativeOasisParsedTokenAccount = (
});
};
const createNativeAuroraParsedTokenAccount = (
provider: Provider,
signerAddress: string | undefined
) => {
return !(provider && signerAddress)
? Promise.reject()
: provider.getBalance(signerAddress).then((balanceInWei) => {
const balanceInEth = ethers.utils.formatEther(balanceInWei);
return createParsedTokenAccount(
signerAddress, //public key
WETH_AURORA_ADDRESS, //Mint key, On the other side this will be wavax, so this is hopefully a white lie.
balanceInWei.toString(), //amount, in wei
WETH_AURORA_DECIMALS,
parseFloat(balanceInEth), //This loses precision, but is a limitation of the current datamodel. This field is essentially deprecated
balanceInEth.toString(), //This is the actual display field, which has full precision.
"ETH", //A white lie for display purposes
"Aurora ETH", //A white lie for display purposes
fantomIcon,
true //isNativeAsset
);
});
};
const createNativeFantomParsedTokenAccount = (
provider: Provider,
signerAddress: string | undefined
@ -886,6 +912,39 @@ function useGetAvailableTokens(nft: boolean = false) {
};
}, [lookupChain, provider, signerAddress, nft, ethNativeAccount]);
useEffect(() => {
let cancelled = false;
if (
signerAddress &&
lookupChain === CHAIN_ID_AURORA &&
!ethNativeAccount &&
!nft
) {
setEthNativeAccountLoading(true);
createNativeAuroraParsedTokenAccount(provider, signerAddress).then(
(result) => {
console.log("create native account returned with value", result);
if (!cancelled) {
setEthNativeAccount(result);
setEthNativeAccountLoading(false);
setEthNativeAccountError("");
}
},
(error) => {
if (!cancelled) {
setEthNativeAccount(undefined);
setEthNativeAccountLoading(false);
setEthNativeAccountError("Unable to retrieve your Fantom balance.");
}
}
);
}
return () => {
cancelled = true;
};
}, [lookupChain, provider, signerAddress, nft, ethNativeAccount]);
useEffect(() => {
let cancelled = false;
if (

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 288 288" version="1.1" viewBox="0 0 288 288" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<style type="text/css">
.st0{fill:#70D44B;}
.st1{fill:#FFFFFF;}
</style>
<path class="st0" d="m144 0c79.5 0 144 64.5 144 144s-64.5 144-144 144-144-64.5-144-144 64.5-144 144-144z"/>
<path class="st1" d="m144 58.8c7.6 0 14.5 4.3 17.9 11.1l56.2 112.5c4.9 9.9 0.9 21.9-9 26.8-2.8 1.4-5.8 2.1-8.9 2.1h-112.4c-11 0-20-9-20-20 0-3.1 0.7-6.2 2.1-8.9l56.2-112.5c3.4-6.9 10.3-11.2 17.9-11.1m0-13.8c-12.8 0-24.5 7.2-30.2 18.7l-56.2 112.5c-8.3 16.7-1.6 36.9 15.1 45.3 4.7 2.3 9.9 3.6 15.1 3.6h112.5c18.6 0 33.8-15.1 33.8-33.7 0-5.2-1.2-10.4-3.6-15.1l-56.3-112.6c-5.7-11.5-17.4-18.7-30.2-18.7z"/>
</svg>

After

Width:  |  Height:  |  Size: 766 B

View File

@ -1,6 +1,7 @@
import {
ChainId,
CHAIN_ID_ACALA,
CHAIN_ID_AURORA,
CHAIN_ID_AVAX,
CHAIN_ID_BSC,
CHAIN_ID_ETH,
@ -17,6 +18,7 @@ import { clusterApiUrl } from "@solana/web3.js";
import { getAddress } from "ethers/lib/utils";
import { CHAIN_CONFIG_MAP } from "../config";
import acalaIcon from "../icons/acala.svg";
import auroraIcon from "../icons/aurora.svg";
import avaxIcon from "../icons/avax.svg";
import bscIcon from "../icons/bsc.svg";
import ethIcon from "../icons/eth.svg";
@ -90,6 +92,11 @@ export const CHAINS: ChainInfo[] =
name: "Acala",
logo: acalaIcon,
},
{
id: CHAIN_ID_AURORA,
name: "Aurora",
logo: auroraIcon,
},
{
id: CHAIN_ID_AVAX,
name: "Avalanche",
@ -173,6 +180,7 @@ export const CHAINS_WITH_NFT_SUPPORT = CHAINS.filter(
id === CHAIN_ID_POLYGON ||
id === CHAIN_ID_OASIS ||
id === CHAIN_ID_SOLANA ||
id === CHAIN_ID_AURORA ||
id === CHAIN_ID_FANTOM ||
id === CHAIN_ID_KARURA ||
id === CHAIN_ID_ACALA
@ -199,6 +207,8 @@ export const getDefaultNativeCurrencySymbol = (chainId: ChainId) =>
? "AVAX"
: chainId === CHAIN_ID_OASIS
? "ROSE"
: chainId === CHAIN_ID_AURORA
? "ETH"
: chainId === CHAIN_ID_FANTOM
? "FTM"
: chainId === CHAIN_ID_KARURA
@ -245,6 +255,12 @@ export const AVAX_NETWORK_CHAIN_ID =
CLUSTER === "mainnet" ? 43114 : CLUSTER === "testnet" ? 43113 : 1381;
export const OASIS_NETWORK_CHAIN_ID =
CLUSTER === "mainnet" ? 42262 : CLUSTER === "testnet" ? 42261 : 1381;
export const AURORA_NETWORK_CHAIN_ID =
CLUSTER === "mainnet"
? 1313161554
: CLUSTER === "testnet"
? 1313161555
: 1381;
export const FANTOM_NETWORK_CHAIN_ID =
CLUSTER === "mainnet" ? 250 : CLUSTER === "testnet" ? 4002 : 1381;
export const KARURA_NETWORK_CHAIN_ID =
@ -264,6 +280,8 @@ export const getEvmChainId = (chainId: ChainId) =>
? AVAX_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_OASIS
? OASIS_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_AURORA
? AURORA_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_FANTOM
? FANTOM_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_KARURA
@ -414,6 +432,27 @@ export const OASIS_TOKEN_BRIDGE_ADDRESS = getAddress(
? "0x88d8004A9BdbfD9D28090A02010C19897a29605c"
: "0x0290FB167208Af455bB137780163b7B7a9a10C16"
);
export const AURORA_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0xBd07292de7b505a4E803CEe286184f7Acf908F5e"
: "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550"
);
export const AURORA_NFT_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0x8F399607E9BA2405D87F5f3e1B78D950b44b2e24"
: "0x26b4afb60d6c903165150c6f0aa14f8016be4aec"
);
export const AURORA_TOKEN_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0xD05eD3ad637b890D68a854d607eEAF11aF456fba"
: "0x0290FB167208Af455bB137780163b7B7a9a10C16"
);
export const FANTOM_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x126783A6Cb203a3E35344528B26ca3a0489a1485"
@ -553,6 +592,8 @@ export const getBridgeAddressForChain = (chainId: ChainId) =>
? AVAX_BRIDGE_ADDRESS
: chainId === CHAIN_ID_OASIS
? OASIS_BRIDGE_ADDRESS
: chainId === CHAIN_ID_AURORA
? AURORA_BRIDGE_ADDRESS
: chainId === CHAIN_ID_FANTOM
? FANTOM_BRIDGE_ADDRESS
: chainId === CHAIN_ID_KARURA
@ -575,6 +616,8 @@ export const getNFTBridgeAddressForChain = (chainId: ChainId) =>
? AVAX_NFT_BRIDGE_ADDRESS
: chainId === CHAIN_ID_OASIS
? OASIS_NFT_BRIDGE_ADDRESS
: chainId === CHAIN_ID_AURORA
? AURORA_NFT_BRIDGE_ADDRESS
: chainId === CHAIN_ID_FANTOM
? FANTOM_NFT_BRIDGE_ADDRESS
: chainId === CHAIN_ID_KARURA
@ -599,6 +642,8 @@ export const getTokenBridgeAddressForChain = (chainId: ChainId) =>
? AVAX_TOKEN_BRIDGE_ADDRESS
: chainId === CHAIN_ID_OASIS
? OASIS_TOKEN_BRIDGE_ADDRESS
: chainId === CHAIN_ID_AURORA
? AURORA_TOKEN_BRIDGE_ADDRESS
: chainId === CHAIN_ID_FANTOM
? FANTOM_TOKEN_BRIDGE_ADDRESS
: chainId === CHAIN_ID_KARURA
@ -617,6 +662,7 @@ export const COVALENT_POLYGON =
CLUSTER === "devnet" ? 137 : POLYGON_NETWORK_CHAIN_ID;
export const COVALENT_AVAX = CLUSTER === "devnet" ? 137 : AVAX_NETWORK_CHAIN_ID;
export const COVALENT_OASIS = CLUSTER === "devnet" ? null : null;
export const COVALENT_AURORA = CLUSTER === "devnet" ? null : null;
export const COVALENT_FANTOM =
CLUSTER === "devnet" ? 250 : FANTOM_NETWORK_CHAIN_ID;
export const COVALENT_KARURA = CLUSTER === "devnet" ? null : null;
@ -638,6 +684,8 @@ export const COVALENT_GET_TOKENS_URL = (
? COVALENT_AVAX
: chainId === CHAIN_ID_OASIS
? COVALENT_OASIS
: chainId === CHAIN_ID_AURORA
? COVALENT_AURORA
: chainId === CHAIN_ID_FANTOM
? COVALENT_FANTOM
: chainId === CHAIN_ID_KARURA
@ -703,6 +751,14 @@ export const WROSE_ADDRESS =
: "0xDDb64fE46a91D46ee29420539FC25FD07c5FEa3E";
export const WROSE_DECIMALS = 18;
export const WETH_AURORA_ADDRESS =
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0x9D29f395524B3C817ed86e2987A14c1897aFF849"
: "0xDDb64fE46a91D46ee29420539FC25FD07c5FEa3E";
export const WETH_AURORA_DECIMALS = 18;
export const WFTM_ADDRESS =
CLUSTER === "mainnet"
? "0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83"