Skip to content

Commit 7b74e1a

Browse files
committed
ADDS multi chain support to v4 swap sdk
1 parent c2eddf0 commit 7b74e1a

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/sdk/v4/NftSwapV4.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
import type { BigNumberish, ContractTransaction } from 'ethers';
77
import { Interface } from '@ethersproject/abi';
88
import invariant from 'tiny-invariant';
9+
import warning from 'tiny-warning';
910
import {
1011
ERC1155__factory,
1112
ERC721__factory,
@@ -59,8 +60,23 @@ export enum SupportedChainIdsV4 {
5960
Mainnet = 1,
6061
Ropsten = 3,
6162
Ganache = 1337,
63+
Polygon = 137,
64+
BSC = 56,
65+
Optimism = 10,
66+
Fantom = 250,
67+
Celo = 42220,
68+
Avalance = 43114,
69+
// Arbitrum = 42161, // soon
6270
}
6371

72+
export const SupportedChainsForV4OrderbookStatusMonitoring = [
73+
SupportedChainIdsV4.Ropsten,
74+
SupportedChainIdsV4.Polygon,
75+
SupportedChainIdsV4.Mainnet,
76+
SupportedChainIdsV4.Optimism,
77+
// SupportedChainIdsV4.Arbitrum,
78+
];
79+
6480
export interface INftSwapV4 extends BaseNftSwap {
6581
signOrder: (
6682
order: NftOrderV4,
@@ -599,6 +615,13 @@ class NftSwapV4 implements INftSwapV4 {
599615
chainId: string,
600616
metadata?: Record<string, string>
601617
) => {
618+
const supportsMonitoring = SupportedChainsForV4OrderbookStatusMonitoring.includes(
619+
parseInt(chainId)
620+
);
621+
warning(
622+
supportsMonitoring,
623+
`Chain ${chainId} does not support live orderbook status monitoring. Orders can be posted to be persisted, but status wont be monitored (e.g. updating status on a fill, cancel, or expiry.)`
624+
);
602625
postOrderToOrderbook(signedOrder, chainId, metadata, {
603626
rootUrl: this.orderbookRootUrl,
604627
});

src/sdk/v4/addresses.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111
"exchange": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
1212
"wrappedNativeToken": "0xc778417e063141139fce010982780140aa0cd5ab"
1313
},
14+
"10": {
15+
"exchange": "0xdef1abe32c034e558cdd535791643c58a13acc10",
16+
"wrappedNativeToken": "0x4200000000000000000000000000000000000006"
17+
},
18+
"250": {
19+
"exchange": "0xdef189deaef76e379df891899eb5a00a94cbc250",
20+
"wrappedNativeToken": "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83"
21+
},
22+
"42220": {
23+
"exchange": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
24+
"wrappedNativeToken": "0x471EcE3750Da237f93B8E339c536989b8978a438"
25+
},
26+
"42161": {
27+
"exchange": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
28+
"wrappedNativeToken": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1"
29+
},
1430
"42": {
1531
"exchange": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
1632
"wrappedNativeToken": "0xd0a1e359811322d97991e03f863a0c30c2cf029c"

0 commit comments

Comments
 (0)