Skip to content

Commit

Permalink
feat: introduce mantle support
Browse files Browse the repository at this point in the history
  • Loading branch information
hzhu committed Oct 6, 2024
1 parent bb6ca92 commit 80de035
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

## Blockchain Support

| <img alt="arbitrum" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/arbitrum/info/logo.png" width="23"/> | <img alt="avalanche" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/avalanchec/info/logo.png" width="20"/> | <img alt="base" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/base/info/logo.png" width="20"/> | <img alt="bnb chain" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/binance/info/logo.png" width="21"/> | <img alt="blast" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/blast/info/logo.png" width="22"/> | <img alt="ethereum" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/ethereum/info/logo.png" width="21"/> | <img alt="linea" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/linea/info/logo.png" width="22"/> | <img alt="optimism" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/optimism/info/logo.png" width="22"/> | <img alt="polygon" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/polygon/info/logo.png" width="22"/> | <img alt="scroll" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/scroll/info/logo.png" width="22"/> |
| :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: |
| Arbitrum | Avalanche | Base | BNB Chain | Blast | Ethereum | Linea | Optimism | Polygon | Scroll |
| <img alt="arbitrum" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/arbitrum/info/logo.png" width="23"/> | <img alt="avalanche" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/avalanchec/info/logo.png" width="20"/> | <img alt="base" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/base/info/logo.png" width="20"/> | <img alt="bnb chain" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/binance/info/logo.png" width="21"/> | <img alt="blast" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/blast/info/logo.png" width="22"/> | <img alt="ethereum" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/ethereum/info/logo.png" width="21"/> | <img alt="linea" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/linea/info/logo.png" width="22"/> | <img alt="mantle" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/mantle/info/logo.png" width="22"/> | <img alt="optimism" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/optimism/info/logo.png" width="22"/> | <img alt="polygon" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/polygon/info/logo.png" width="22"/> | <img alt="scroll" src="https://raw.githubusercontent.com/rainbow-me/assets/master/blockchains/scroll/info/logo.png" width="22"/> |
| :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: |
| Arbitrum | Avalanche | Base | BNB Chain | Blast | Ethereum | Linea | Mantle | Optimism | Polygon | Scroll |

## Overview

Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
blast,
linea,
scroll,
mantle,
mainnet,
polygon,
arbitrum,
Expand Down Expand Up @@ -50,6 +51,7 @@ export const NATIVE_SYMBOL_BY_CHAIN_ID: { [key in SupportedChainId]: string } =
[blast.id]: blast.nativeCurrency.symbol,
[linea.id]: linea.nativeCurrency.symbol,
[scroll.id]: scroll.nativeCurrency.symbol,
[mantle.id]: mantle.nativeCurrency.symbol,
[mainnet.id]: mainnet.nativeCurrency.symbol,
[polygon.id]: polygon.nativeCurrency.symbol,
[optimism.id]: optimism.nativeCurrency.symbol,
Expand Down
30 changes: 30 additions & 0 deletions src/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1081,3 +1081,33 @@ test("parse a swap on Blast (ETH for ezETH) with execute", async () => {
},
});
});

// https://mantlescan.xyz/tx/0xbd89bd8f580e5606c046feac8b0d72e321009cfed361c9919eb4845999ea79a4
test("parse a swap on Mantle (WETH for mETH) with execute", async () => {
const publicClient = createPublicClient({
chain: blast,
transport: http(
`https://mantle-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`
),
}) as PublicClient<Transport, Chain>;

const transactionHash = `0xbd89bd8f580e5606c046feac8b0d72e321009cfed361c9919eb4845999ea79a4`;

const result = await parseSwap({
publicClient,
transactionHash,
});

expect(result).toEqual({
tokenIn: {
symbol: "WETH",
amount: "0.0001",
address: "0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111",
},
tokenOut: {
symbol: "mETH",
amount: "0.000097870496599353",
address: "0xcDA86A272531e8640cD7F1a92c01839911B90bb0",
},
});
});
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
blast,
linea,
scroll,
mantle,
mainnet,
polygon,
arbitrum,
Expand All @@ -27,6 +28,7 @@ export type SupportedChainId =
| typeof blast.id
| typeof linea.id
| typeof scroll.id
| typeof mantle.id
| typeof mainnet.id
| typeof polygon.id
| typeof arbitrum.id
Expand Down
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
blast,
linea,
scroll,
mantle,
mainnet,
polygon,
arbitrum,
Expand All @@ -29,6 +30,7 @@ export function isChainIdSupported(
blast.id,
linea.id,
scroll.id,
mantle.id,
polygon.id,
mainnet.id,
arbitrum.id,
Expand Down

0 comments on commit 80de035

Please sign in to comment.