Skip to content

Commit

Permalink
Release v0.3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
dash-yuga committed Nov 8, 2024
1 parent 84edd97 commit 56a7396
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 27 deletions.
152 changes: 144 additions & 8 deletions lib/components/ui/modal/ChainTokenSelectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
UsdcEthMainnetContract,
UsdtArbMainnetContract,
UsdtEthMainnetContract,
WethArbMainnetContract,
WethEthMainnetContract,
} from '../../../utils/utils.ts';
import { Address, isAddressEqual, zeroAddress } from 'viem';

Expand Down Expand Up @@ -65,23 +67,157 @@ const limitTokensBySource = (
sourceToken: TokenInfo,
destChain: ChainId,
): string[] | undefined => {
if (sourceToken.chainId === ChainId.APE && destChain === ChainId.ETHEREUM) {
if (
sourceToken.chainId === ChainId.ETHEREUM &&
(destChain === ChainId.ARBITRUM || destChain === ChainId.APE)
) {
// Source: ETH-USDC, ETH-USDT, ETH-DAI
if (
isAddressEqual(sourceToken.address as Address, UsdcEthMainnetContract) ||
isAddressEqual(sourceToken.address as Address, UsdtEthMainnetContract) ||
isAddressEqual(sourceToken.address as Address, DaiEthMainnetContract)
) {
return [ApeUsdOmnichainContract]; // APE-APEUSD or ARB-APEUSD
}

// Source: ETH-ETH, ETH-WETH, ETH-stETH
if (
isAddressEqual(sourceToken.address as Address, zeroAddress) ||
isAddressEqual(sourceToken.address as Address, WethEthMainnetContract) ||
isAddressEqual(sourceToken.address as Address, StethEthMainnetContract)
) {
return [ApeEthOmnichainContract]; // APE-APEETH or ARB-APEETH
}

// Source: ETH-APE
if (
isAddressEqual(
sourceToken.address as Address,
ApeCoinMainnetEthereumContract,
)
) {
if (destChain === ChainId.ARBITRUM) {
return [ApeCoinMainnetArbitrumContract]; // APE-ARB
}
if (destChain === ChainId.APE) {
return [zeroAddress]; // APE-APE
}
}
}

if (sourceToken.chainId === ChainId.ARBITRUM) {
// Source: ARB-USDC
if (
isAddressEqual(sourceToken.address as Address, UsdcArbMainnetContract)
) {
if (destChain === ChainId.APE) {
return [ApeUsdOmnichainContract]; // APE-APEUSD
}
return [];
}
// Source: ARB-USDT
if (
isAddressEqual(sourceToken.address as Address, UsdtArbMainnetContract)
) {
if (destChain === ChainId.APE) {
return [ApeUsdOmnichainContract]; // APE-APEUSD
}
return [];
}
// Source: ARB-DAI
if (isAddressEqual(sourceToken.address as Address, DaiArbMainnetContract)) {
if (destChain === ChainId.APE) {
return [ApeUsdOmnichainContract]; // APE-APEUSD
}
return [];
}
// Source: ARB-APEUSD
if (
isAddressEqual(sourceToken.address as Address, ApeUsdOmnichainContract)
) {
if (destChain === ChainId.APE) {
return [ApeUsdOmnichainContract]; // APE-APEUSD
}
return [];
}
// Source: ARB-ETH
if (isAddressEqual(sourceToken.address as Address, zeroAddress)) {
return [ApeCoinMainnetEthereumContract]; // ETH-APE
if (destChain === ChainId.APE) {
return [ApeEthOmnichainContract]; // APE-APEETH
}
return [];
}
// Source: ARB-WETH
if (
isAddressEqual(sourceToken.address as Address, WethArbMainnetContract)
) {
if (destChain === ChainId.APE) {
return [ApeEthOmnichainContract]; // APE-APEETH
}
return [];
}
// Source: ARB-APEETH
if (
isAddressEqual(sourceToken.address as Address, ApeEthOmnichainContract)
) {
if (destChain === ChainId.APE) {
return [ApeEthOmnichainContract]; // APE-APEETH
}
return [];
}
// Source: ARB-APE
if (
isAddressEqual(
sourceToken.address as Address,
ApeCoinMainnetArbitrumContract,
)
) {
if (destChain === ChainId.APE) {
return [zeroAddress]; // APE-APE
}
if (destChain === ChainId.ETHEREUM) {
return [ApeCoinMainnetEthereumContract]; // ETH-APE
}
return [];
}
}

if (sourceToken.chainId === ChainId.APE) {
// Source: APE-APEUSD
if (
isAddressEqual(sourceToken.address as Address, ApeUsdOmnichainContract)
) {
return [
'0x6B175474E89094C44Da98b954EedeAC495271d0F', // ETH-DAI
];
if (destChain === ChainId.ETHEREUM) {
return [DaiEthMainnetContract]; // ETH-DAI
}
if (destChain === ChainId.ARBITRUM) {
return [ApeUsdOmnichainContract]; // ARB-APEUSD
}
return [];
}

// Source: APE-APEETH
if (
isAddressEqual(sourceToken.address as Address, ApeEthOmnichainContract)
) {
return [
'0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84', // ETH-stETH
];
if (destChain === ChainId.ETHEREUM) {
return [StethEthMainnetContract]; // ETH-stETH
}
if (destChain === ChainId.ARBITRUM) {
return [ApeEthOmnichainContract]; // ARB-APEETH
}
return [];
}

// Source: APE-APE
if (isAddressEqual(sourceToken.address as Address, zeroAddress)) {
if (destChain === ChainId.ARBITRUM) {
return [ApeCoinMainnetArbitrumContract]; // APE-ARB
}
if (destChain === ChainId.ETHEREUM) {
return [ApeCoinMainnetEthereumContract]; // ETH-APE
}
return [];
}
}
};
Expand Down
1 change: 1 addition & 0 deletions lib/hooks/useTokenAmounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const useTokenAmounts = (
address,
chainId: token.token.chainId,
selectTokens: [token.token.address],
enable: address !== undefined,
});

const findCurrentBalance = useCallback(
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export const DaiEthMainnetContract =
'0x6B175474E89094C44Da98b954EedeAC495271d0F';
export const StethEthMainnetContract =
'0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84';
export const WethEthMainnetContract =
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';

/** ARB mainnet stables */
export const DaiArbMainnetContract =
Expand All @@ -133,6 +135,8 @@ export const UsdtArbMainnetContract =
'0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9';
export const UsdcArbMainnetContract =
'0xaf88d065e77c8cC2239327C5EDb3A432268e5831';
export const WethArbMainnetContract =
'0x82aF49447D8a07e3bd95BD0d56f35241523fBab1';

export const isStableToken = (contractAddress: string | Address): boolean =>
[
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@yuga-labs/ape-portal-public",
"description": "ApeChain Portal. Offers a set of components to interact with the ApeChain blockchain.",
"version": "0.3.11",
"version": "0.3.12",
"license": "APEPORTAL-1.0",
"type": "module",
"main": "./dist/cjs/index.js",
Expand Down
16 changes: 8 additions & 8 deletions test/components/ui/__snapshots__/Portal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ exports[`ApePortal > renders the default tab correctly with onramp disabled 1`]
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -371,7 +371,7 @@ exports[`ApePortal > renders the default tab correctly with onramp disabled 1`]
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
</div>
Expand Down Expand Up @@ -733,7 +733,7 @@ exports[`ApePortal > renders the default tab correctly with onramp disabled 1`]
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -906,7 +906,7 @@ exports[`ApePortal > renders the default tab correctly with onramp disabled 1`]
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
</div>
Expand Down Expand Up @@ -1337,7 +1337,7 @@ exports[`ApePortal > renders the default tab correctly with onramp enabled 1`] =
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -1510,7 +1510,7 @@ exports[`ApePortal > renders the default tab correctly with onramp enabled 1`] =
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
</div>
Expand Down Expand Up @@ -1944,7 +1944,7 @@ exports[`ApePortal > renders the default tab correctly with onramp enabled 1`] =
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -2117,7 +2117,7 @@ exports[`ApePortal > renders the default tab correctly with onramp enabled 1`] =
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions test/components/ui/__snapshots__/TokenInputModule.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exports[`components/ui/TokenInputModule > should NOT show destination wallet add
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -220,7 +220,7 @@ exports[`components/ui/TokenInputModule > should NOT show destination wallet add
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -393,7 +393,7 @@ exports[`components/ui/TokenInputModule > should only render MaxButton when srcT
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -510,7 +510,7 @@ exports[`components/ui/TokenInputModule > should only render MaxButton when srcT
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -683,7 +683,7 @@ exports[`components/ui/TokenInputModule > should render MaxButton disabled if wa
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -800,7 +800,7 @@ exports[`components/ui/TokenInputModule > should render MaxButton disabled if wa
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
<button
Expand Down Expand Up @@ -1261,7 +1261,7 @@ exports[`components/ui/TokenInputModule > should render TokenInputModule 1`] = `
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
</div>
Expand Down Expand Up @@ -1368,7 +1368,7 @@ exports[`components/ui/TokenInputModule > should render TokenInputModule 1`] = `
<span
class="aw-text-[15px] aw-font-normal aw-leading-[18px] aw-tracking-tight aw-text-white aw-opacity-70"
>
Loading...
0
</span>
</div>
</div>
Expand Down

0 comments on commit 56a7396

Please sign in to comment.