Skip to content

Commit 313ed85

Browse files
committed
convert bigint chainids to enum
1 parent b06f96e commit 313ed85

File tree

10 files changed

+20
-19
lines changed

10 files changed

+20
-19
lines changed

packages/checkout/sdk/src/balances/balances.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('balances', () => {
5454

5555
jest.mock('../connect', () => ({
5656
getNetworkInfo: jest.fn().mockResolvedValue({
57-
chainId: BigInt(ChainId.ETHEREUM),
57+
chainId: ChainId.ETHEREUM,
5858
name: ChainName.ETHEREUM,
5959
isSupported: true,
6060
nativeCurrency: {

packages/checkout/sdk/src/network/network.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('network functions', () => {
168168
]);
169169
const copyZkevmNetworkInfo = zkevmNetworkInfo as unknown as NetworkInfo;
170170
copyZkevmNetworkInfo.isSupported = true;
171-
copyZkevmNetworkInfo.chainId = BigInt(zkevmNetworkInfo.chainId);
171+
copyZkevmNetworkInfo.chainId = zkevmNetworkInfo.chainId;
172172
expect(switchNetworkResult.network).toEqual(copyZkevmNetworkInfo);
173173
});
174174

packages/checkout/sdk/src/network/network.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function getNetworkAllowList(
8080
if (newNetwork) {
8181
allowedNetworks.push({
8282
name: newNetwork.chainName,
83-
chainId: BigInt(parseInt(newNetwork.chainIdHex, 16)),
83+
chainId: parseInt(newNetwork.chainIdHex, 16),
8484
nativeCurrency: newNetwork.nativeCurrency,
8585
isSupported: true,
8686
});
@@ -107,21 +107,21 @@ export async function getNetworkInfo(
107107
const chainIdNetworkInfo = networkMap.get(Number(network.chainId));
108108
return {
109109
name: chainIdNetworkInfo!.chainName,
110-
chainId: BigInt(parseInt(chainIdNetworkInfo!.chainIdHex, 16)),
110+
chainId: parseInt(chainIdNetworkInfo!.chainIdHex, 16),
111111
nativeCurrency: chainIdNetworkInfo!.nativeCurrency,
112112
isSupported: true,
113113
};
114114
}
115115
return {
116-
chainId: network.chainId,
116+
chainId: Number(network.chainId),
117117
name: network.name,
118118
isSupported: false,
119119
} as NetworkInfo;
120120
} catch (err) {
121121
const chainId = await getUnderlyingChainId(provider);
122122
const isSupported = Array.from(networkMap.keys()).includes(Number(chainId));
123123
return {
124-
chainId,
124+
chainId: Number(chainId),
125125
isSupported,
126126
} as NetworkInfo;
127127
}

packages/checkout/sdk/src/provider/validateProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export async function validateProvider(
6666
type: NetworkFilterTypes.ALL,
6767
});
6868

69-
const isAllowed = allowedNetworks.networks.some((network) => network.chainId === underlyingChainId);
69+
const isAllowed = allowedNetworks.networks.some((network) => network.chainId === Number(underlyingChainId));
7070

7171
if (!isAllowed && !options.allowUnsupportedProvider) {
7272
throw new CheckoutError(

packages/checkout/sdk/src/readOnlyProviders/readOnlyProviders.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('read only providers', () => {
2323
const getNetworkAllListMock = jest.fn().mockResolvedValue({
2424
networks: [
2525
{
26-
chainId: BigInt(ChainId.IMTBL_ZKEVM_TESTNET),
26+
chainId: ChainId.IMTBL_ZKEVM_TESTNET,
2727
name: ChainName.IMTBL_ZKEVM_TESTNET,
2828
isSupported: true,
2929
nativeCurrency: {},

packages/checkout/sdk/src/sdk.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('Connect', () => {
9898
const getNetworkAllListMock = jest.fn().mockResolvedValue({
9999
networks: [
100100
{
101-
chainId: BigInt(ChainId.ETHEREUM),
101+
chainId: ChainId.ETHEREUM,
102102
name: ChainName.ETHEREUM,
103103
isSupported: true,
104104
nativeCurrency: {},
@@ -788,7 +788,7 @@ describe('Connect', () => {
788788

789789
networkInfoResult = {
790790
name: ChainName.ETHEREUM,
791-
chainId: BigInt(ChainId.ETHEREUM),
791+
chainId: ChainId.ETHEREUM,
792792
nativeCurrency: {
793793
name: 'ETHEREUM',
794794
symbol: 'ETH',

packages/checkout/sdk/src/transaction/transaction.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('transaction', () => {
1818
const mockSendTransaction = jest.fn().mockResolvedValue(transactionResponse);
1919
const mockProvider = {
2020
getNetwork: jest.fn().mockReturnValue({
21-
chainId: BigInt(ChainId.IMTBL_ZKEVM_TESTNET),
21+
chainId: ChainId.IMTBL_ZKEVM_TESTNET,
2222
} as NetworkInfo),
2323
getSigner: jest.fn().mockReturnValue({
2424
sendTransaction: mockSendTransaction,
@@ -45,7 +45,7 @@ describe('transaction', () => {
4545
it('should return errored status if transaction errors', async () => {
4646
const mockProvider = {
4747
getNetwork: jest.fn().mockReturnValue({
48-
chainId: BigInt(ChainId.ETHEREUM),
48+
chainId: (ChainId.ETHEREUM),
4949
} as NetworkInfo),
5050
getSigner: jest.fn().mockReturnValue({
5151
sendTransaction: () => {
@@ -76,7 +76,7 @@ describe('transaction', () => {
7676
it('should return insufficient funds status if transaction errors with insufficient funds', async () => {
7777
const mockProvider = {
7878
getNetwork: jest.fn().mockReturnValue({
79-
chainId: BigInt(ChainId.ETHEREUM),
79+
chainId: ChainId.ETHEREUM,
8080
} as NetworkInfo),
8181
getSigner: jest.fn().mockReturnValue({
8282
sendTransaction: () => {
@@ -109,7 +109,7 @@ describe('transaction', () => {
109109
it('should return user rejected request status if transaction errors with action rejected', async () => {
110110
const mockProvider = {
111111
getNetwork: jest.fn().mockReturnValue({
112-
chainId: BigInt(ChainId.ETHEREUM),
112+
chainId: ChainId.ETHEREUM,
113113
} as NetworkInfo),
114114
getSigner: jest.fn().mockReturnValue({
115115
sendTransaction: () => {
@@ -150,7 +150,7 @@ describe('transaction', () => {
150150
const mockSendTransaction = jest.fn().mockResolvedValue(transactionResponse);
151151
const mockProvider = {
152152
getNetwork: jest.fn().mockResolvedValue({
153-
chainId: BigInt(ChainId.IMTBL_ZKEVM_TESTNET),
153+
chainId: ChainId.IMTBL_ZKEVM_TESTNET,
154154
} as NetworkInfo),
155155
getSigner: jest.fn().mockResolvedValue({
156156
sendTransaction: mockSendTransaction,
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
import { ChainId } from './chains';
12
import { TokenInfo } from './tokenInfo';
23

34
/**
45
* Represents information about a network.
56
* @interface NetworkInfo
67
* @property {string} name - The name of the network.
7-
* @property {bigint} chainId - The chain ID of the network.
8+
* @property {ChainId} chainId - The chain ID of the network.
89
* @property {TokenInfo} nativeCurrency - Information about the native currency of the network.
910
* @property {boolean} isSupported - Indicates whether the network is supported.
1011
*/
1112
export interface NetworkInfo {
1213
name: string;
13-
chainId: bigint;
14+
chainId: ChainId;
1415
nativeCurrency: TokenInfo;
1516
isSupported: boolean;
1617
}

packages/checkout/widgets-lib/src/widgets/swap/context/SwapContext.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('WalletContext', () => {
2424
type: SwapActions.SET_NETWORK,
2525
network: {
2626
name: 'Ethereum',
27-
chainId: BigInt(ChainId.ETHEREUM),
27+
chainId: ChainId.ETHEREUM,
2828
nativeCurrency: {
2929
symbol: 'ETH',
3030
decimals: 18,

packages/checkout/widgets-lib/src/widgets/wallet/context/WalletContext.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('WalletContext', () => {
1616
type: WalletActions.SET_NETWORK,
1717
network: {
1818
name: 'Ethereum',
19-
chainId: BigInt(ChainId.ETHEREUM),
19+
chainId: ChainId.ETHEREUM,
2020
nativeCurrency: {
2121
symbol: 'ETH',
2222
decimals: 18,

0 commit comments

Comments
 (0)