Skip to content

Commit c6d74c4

Browse files
committed
fix: enforce transport-per-chain precondition on createEvmTransactionAdapter
1 parent 0af3215 commit c6d74c4

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/sdk/core/evm/transaction.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ describe('createEvmTransactionAdapter', () => {
3939
)
4040
})
4141

42+
it('throws when a chain has no corresponding transport', () => {
43+
expect(() =>
44+
createEvmTransactionAdapter({
45+
chains: [mainnet],
46+
transports: {},
47+
}),
48+
).toThrow('chain "Ethereum" (id: 1) has no transport configured')
49+
})
50+
4251
// ---------------------------------------------------------------------------
4352
// structural / metadata
4453
// ---------------------------------------------------------------------------

src/sdk/core/evm/transaction.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ export function createEvmTransactionAdapter(
6161
'createEvmTransactionAdapter requires at least one chain. Provide chains in config.chains.',
6262
)
6363
}
64+
for (const chain of config.chains) {
65+
if (!config.transports[chain.id]) {
66+
throw new Error(
67+
`createEvmTransactionAdapter: chain "${chain.name}" (id: ${chain.id}) has no transport configured.`,
68+
)
69+
}
70+
}
6471
const publicClients = new Map<number, PublicClient>(
6572
config.chains.map((chain) => [
6673
chain.id,

0 commit comments

Comments
 (0)