Skip to content

Commit 992cf9c

Browse files
committed
ADDS convenience method to get wrapped token for chain
1 parent 099ad28 commit 992cf9c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/sdk/v4/NftSwapV4.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
} from './orderbook';
5757
import { DIRECTION_MAPPING, OrderStatusV4, TradeDirection } from './enums';
5858
import { CONTRACT_ORDER_VALIDATOR } from './properties';
59+
import { getWrappedNativeToken } from '../../utils/addresses';
5960

6061
export enum SupportedChainIdsV4 {
6162
Mainnet = 1,
@@ -347,6 +348,10 @@ class NftSwapV4 implements INftSwapV4 {
347348
);
348349
}
349350

351+
getWrappedTokenAddress = (chainId: number | string) => {
352+
return getWrappedNativeToken(chainId);
353+
}
354+
350355
buildCollectionBasedOrder = (
351356
erc20ToSell: UserFacingERC20AssetDataSerializedV4,
352357
nftCollectionToBid: {

src/utils/addresses.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { SupportedChainIdsV4 } from '../sdk';
2+
import defaultAddresses from '../sdk/v4/addresses.json';
3+
4+
export const getWrappedNativeToken = (
5+
chainId: number | string
6+
): string | null => {
7+
const chainIdString = chainId.toString(10);
8+
const zeroExAddresses:
9+
| { exchange: string; wrappedNativeToken: string }
10+
| undefined =
11+
defaultAddresses[chainIdString as unknown as SupportedChainIdsV4];
12+
return zeroExAddresses?.wrappedNativeToken ?? null;
13+
};

0 commit comments

Comments
 (0)