Skip to content

Commit 410971b

Browse files
committed
feat: support new chain, blast
1 parent 9c4f2b1 commit 410971b

File tree

5 files changed

+71
-4
lines changed

5 files changed

+71
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
## Blockchain Support
1010

11-
| <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="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"/> |
12-
| :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: |
13-
| Arbitrum | Avalanche | Base | BNB Chain | Ethereum | Linea | Optimism | Polygon | Scroll |
11+
| <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"/> |
12+
| :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: |
13+
| Arbitrum | Avalanche | Base | BNB Chain | Blast | Ethereum | Linea | Optimism | Polygon | Scroll |
1414

1515
## Overview
1616

src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
bsc,
33
base,
4+
blast,
45
linea,
56
scroll,
67
mainnet,
@@ -46,6 +47,7 @@ export const NATIVE_SYMBOL_BY_CHAIN_ID: { [key in SupportedChainId]: string } =
4647
{
4748
[bsc.id]: bsc.nativeCurrency.symbol,
4849
[base.id]: base.nativeCurrency.symbol,
50+
[blast.id]: blast.nativeCurrency.symbol,
4951
[linea.id]: linea.nativeCurrency.symbol,
5052
[scroll.id]: scroll.nativeCurrency.symbol,
5153
[mainnet.id]: mainnet.nativeCurrency.symbol,

src/tests/index.test.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "viem";
88
import {
99
base,
10+
blast,
1011
linea,
1112
scroll,
1213
polygon,
@@ -1020,3 +1021,63 @@ test("parse a swap on Linear (USDC for WETH) with execute", async () => {
10201021
},
10211022
});
10221023
});
1024+
1025+
// https://blastscan.io/tx/0x2cdcf1c74ff01657a2d8540be3e820e21312fd5b929ae1dc887f1a45418a4bf4
1026+
test("parse a swap on Blast (YOLO for USDB) with execute", async () => {
1027+
const publicClient = createPublicClient({
1028+
chain: blast,
1029+
transport: http(
1030+
`https://blast-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`
1031+
),
1032+
}) as PublicClient<Transport, Chain>;
1033+
1034+
const transactionHash = `0x2cdcf1c74ff01657a2d8540be3e820e21312fd5b929ae1dc887f1a45418a4bf4`;
1035+
1036+
const result = await parseSwap({
1037+
publicClient,
1038+
transactionHash,
1039+
});
1040+
1041+
expect(result).toEqual({
1042+
tokenIn: {
1043+
symbol: "YOLO",
1044+
amount: "10004.483202235712364987",
1045+
address: "0xf77dd21c5ce38ac08786BE35Ef1d1DeC1a6a15F3",
1046+
},
1047+
tokenOut: {
1048+
symbol: "USDB",
1049+
amount: "22.673803957148435593",
1050+
address: "0x4300000000000000000000000000000000000003",
1051+
},
1052+
});
1053+
});
1054+
1055+
// https://blastscan.io/tx/0x62b094c45cc2506d60d44afa50bc54e699c09278be5050d8510a42ab1c8fa31f
1056+
test("parse a swap on Blast (ETH for ezETH) with execute", async () => {
1057+
const publicClient = createPublicClient({
1058+
chain: blast,
1059+
transport: http(
1060+
`https://blast-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`
1061+
),
1062+
}) as PublicClient<Transport, Chain>;
1063+
1064+
const transactionHash = `0x62b094c45cc2506d60d44afa50bc54e699c09278be5050d8510a42ab1c8fa31f`;
1065+
1066+
const result = await parseSwap({
1067+
publicClient,
1068+
transactionHash,
1069+
});
1070+
1071+
expect(result).toEqual({
1072+
tokenIn: {
1073+
symbol: "ETH",
1074+
amount: "0.0005",
1075+
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
1076+
},
1077+
tokenOut: {
1078+
symbol: "ezETH",
1079+
amount: "0.000491534297265178",
1080+
address: "0x2416092f143378750bb29b79eD961ab195CcEea5",
1081+
},
1082+
});
1083+
});

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
bsc,
33
base,
4+
blast,
45
linea,
56
scroll,
67
mainnet,
@@ -23,6 +24,7 @@ import type {
2324
export type SupportedChainId =
2425
| typeof bsc.id
2526
| typeof base.id
27+
| typeof blast.id
2628
| typeof linea.id
2729
| typeof scroll.id
2830
| typeof mainnet.id

src/utils/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { fromHex, erc20Abi, getAddress, formatUnits, formatEther } from "viem";
22
import {
33
bsc,
44
base,
5+
blast,
6+
linea,
57
scroll,
68
mainnet,
79
polygon,
810
arbitrum,
911
optimism,
1012
avalanche,
11-
linea,
1213
} from "viem/chains";
1314
import { NATIVE_SYMBOL_BY_CHAIN_ID, NATIVE_TOKEN_ADDRESS } from "../constants";
1415
import type { Address } from "viem";
@@ -25,6 +26,7 @@ export function isChainIdSupported(
2526
const supportedChainIds: number[] = [
2627
bsc.id,
2728
base.id,
29+
blast.id,
2830
linea.id,
2931
scroll.id,
3032
polygon.id,

0 commit comments

Comments
 (0)