bridge_ui: fix v1 asset check

This commit is contained in:
Chase Moran 2021-12-21 11:59:56 -05:00 committed by Evan Gray
parent 86c3423b6a
commit d8d3a92dae
4 changed files with 19 additions and 11 deletions

View File

@ -142,11 +142,11 @@ export default function EvmTokenPicker(
}
let v1 = false;
try {
v1 = await isWormholev1(provider, account.publicKey, chainId);
v1 = await isWormholev1(provider, account.mintKey, chainId);
} catch (e) {
//For now, just swallow this one.
}
const migration = isMigrationEligible(account.publicKey);
const migration = isMigrationEligible(account.mintKey);
if (v1 === true && !migration) {
throw new Error(
"Wormhole v1 assets cannot be transferred with this bridge."

View File

@ -145,7 +145,7 @@ export default function SolanaSourceTokenSelector(
const isWormholev1 = useCallback(
(address: string) => {
//This is a v1 wormhole token on testnet
//const testAddress = "4QixXecTZ4zdZGa39KH8gVND5NZ2xcaB12wiBhE4S7rn";
//address = "4QixXecTZ4zdZGa39KH8gVND5NZ2xcaB12wiBhE4S7rn";
if (!props.mintAccounts?.data) {
return true; //These should never be null by this point
@ -178,8 +178,8 @@ export default function SolanaSourceTokenSelector(
//swallow for now
}
if (v1) {
Promise.reject(
if (v1 && !isMigrationEligible(newValue.mintKey)) {
throw Error(
"Wormhole v1 assets should not be transferred with this bridge."
);
}

View File

@ -313,11 +313,14 @@ export default function TokenPicker({
}
await onChange(newOption);
closeDialog();
} catch (e) {
console.error(e);
setSelectionError(
"Unable to retrieve required information about this token. Ensure your wallet is connected, then refresh the list."
);
} catch (e: any) {
if (e.message?.includes("v1")) {
setSelectionError(e.message);
} else {
setSelectionError(
"Unable to retrieve required information about this token. Ensure your wallet is connected, then refresh the list."
);
}
}
},
[getAddress, onChange, closeDialog]

View File

@ -665,7 +665,12 @@ export const MIGRATION_ASSET_MAP = new Map<string, string>(
],
]
: CLUSTER === "testnet"
? []
? [
[
"orcarKHSqC5CDDsGbho8GKvwExejWHxTqGzXgcewB9L", //This is not actually a v1 asset
"orcarKHSqC5CDDsGbho8GKvwExejWHxTqGzXgcewB9L",
],
]
: [
// [
// "2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ",