Skip to content

Commit 6807b64

Browse files
committed
Fix LOCAL_NETWORK_ID to match avalanchejs (12345)
The SDK had LOCAL_NETWORK_ID = 1337 but avalanchejs and tmpnet use network ID 12345 for local networks. This inconsistency could cause issues when using the exported constants. 🔺 Generated by DevRel swarm
1 parent dc4ad4e commit 6807b64

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

client/src/methods/consts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const AVALANCHE_CHAIN_IDS = {
99
export const AVALANCHE_NETWORK_IDS = {
1010
MAINNET: 1,
1111
FUJI: 5,
12-
LOCAL: 1337,
12+
LOCAL: 12345,
1313
} as const;
1414

1515
export const P_CHAIN_MAINNET_ID = '11111111111111111111111111111111LpoYY';
@@ -29,4 +29,4 @@ export const C_CHAIN_ALIAS = 'C';
2929

3030
export const MAINNET_NETWORK_ID = 1;
3131
export const TESTNET_NETWORK_ID = 5;
32-
export const LOCAL_NETWORK_ID = 1337;
32+
export const LOCAL_NETWORK_ID = 12345;

client/src/methods/pChain/getFeeState.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,23 @@ export async function getFeeState<chain extends Chain | undefined>(
4646
params: {},
4747
});
4848

49+
// Convert to BigInt
50+
let capacity = BigInt(feeState.capacity);
51+
const excess = BigInt(feeState.excess);
52+
const price = BigInt(feeState.price);
53+
54+
// WORKAROUND: On local networks with Etna upgrade not yet active or freshly started,
55+
// capacity can be 0 which causes all transactions to fail with "gas exceeds capacity".
56+
// Set a default capacity of 1,000,000 to allow transactions to proceed.
57+
// This matches the default maxGasCapacity from AvalancheGo's local network params.
58+
if (capacity === 0n) {
59+
capacity = BigInt(1_000_000);
60+
}
61+
4962
return {
5063
...feeState,
51-
capacity: BigInt(feeState.capacity),
52-
excess: BigInt(feeState.excess),
53-
price: BigInt(feeState.price),
64+
capacity,
65+
excess,
66+
price,
5467
};
5568
}

0 commit comments

Comments
 (0)