Skip to content

Commit b29cef6

Browse files
authored
Add monad to CHAINS export (#794)
* add monad to CHAINS constant * add changeset * test for CHAINS export * refactor less of test
1 parent 6699831 commit b29cef6

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

.changeset/smart-tools-rhyme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@balancer/sdk": patch
3+
---
4+
5+
add monad to CHAINS export

src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
sonic,
2121
plasma,
2222
xLayer,
23+
monad,
2324
} from 'viem/chains';
2425
import { monadTestnet, hyperEVM } from './customChains';
2526
export const ZERO_ADDRESS: Address =
@@ -131,6 +132,7 @@ export const CHAINS: Record<number, Chain> = {
131132
[ChainId.SEPOLIA]: sepolia,
132133
[ChainId.SONIC]: sonic,
133134
[ChainId.MONAD_TESTNET]: monadTestnet,
135+
[ChainId.MONAD]: monad,
134136
[ChainId.HYPEREVM]: hyperEVM,
135137
[ChainId.PLASMA]: plasma,
136138
[ChainId.X_LAYER]: xLayer,

test/validateNewChainSetup.test.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { API_CHAIN_NAMES, ChainId } from '@/utils';
2-
import { NATIVE_ASSETS } from '@/utils/constants';
2+
import { CHAINS, NATIVE_ASSETS } from '@/utils/constants';
33
import { SorSwapPaths } from '@/data/providers/balancer-api/modules/sorSwapPaths';
44
import { BalancerApiClient } from '@/data/providers/balancer-api/client';
55

@@ -47,6 +47,7 @@ describe('Balancer API (sdk) supports all API chains', () => {
4747

4848
expect(missingEntries).toHaveLength(0);
4949
});
50+
5051
test('The Balancer Api (sdk) supports the api chains', () => {
5152
const sorSwapPaths = new SorSwapPaths(
5253
null as unknown as BalancerApiClient,
@@ -58,24 +59,19 @@ describe('Balancer API (sdk) supports all API chains', () => {
5859
}
5960
}
6061
});
61-
});
62-
describe('Native asset is defined for all API chains', () => {
63-
let supportedChains: SupportedChain[] = [];
64-
65-
beforeAll(async () => {
66-
const chainNames = await fetchSupportedChains(API_ENDPOINT);
6762

68-
// Build array of objects: { name, chainId }
69-
supportedChains = chainNames.map((name: string) => {
70-
// Find the chainId for this name in API_CHAIN_NAMES
71-
const chainIdEntry = Object.entries(API_CHAIN_NAMES).find(
72-
([, apiName]) => apiName === name,
73-
);
74-
return {
75-
name,
76-
chainId: chainIdEntry ? Number(chainIdEntry[0]) : undefined,
77-
};
78-
});
63+
test('API supported chains have CHAINS entries', () => {
64+
const missingChains: string[] = [];
65+
for (const { name, chainId } of supportedChains) {
66+
if (chainId === undefined) continue;
67+
if (!CHAINS[chainId]) {
68+
missingChains.push(`${name} (${chainId})`);
69+
}
70+
}
71+
if (missingChains.length > 0) {
72+
console.error('Missing CHAINS entries for:', missingChains);
73+
}
74+
expect(missingChains).toHaveLength(0);
7975
});
8076

8177
test('Native asset is defined for all API chains', () => {

0 commit comments

Comments
 (0)