add dynamic gasfee pricing as a signing client option - Feemarket/Osmosis
Summary
Adds automatic gas price discovery for chains with dynamic feemarket modules (Osmosis EIP-1559 and Skip feemarket). Instead of manually setting static gas prices, CosmJS can now query current prices from the chain, preventing transaction failures from outdated pricing.
Changes
- New feemarket.ts: Query dynamic gas prices from Osmosis EIP-1559 and Skip feemarket modules
- Updated clients: SigningStargateClient and SigningCosmWasmClient now support DynamicGasPriceConfig
- Refactoring: Extracted calculateFeeForTransaction() helper
- Tests: Some unit tests and an end-to-end validation on Osmosis and Neutron testnets
Usage
const client = await SigningStargateClient.connectWithSigner(rpc, signer, {
gasPrice: {
denom: "uosmo",
multiplier: 1.3,
minGasPrice: GasPrice.fromString("0.0025uosmo"),
maxGasPrice: GasPrice.fromString("0.1uosmo"),
}
});
// Gas price queried automatically per transaction
await client.signAndBroadcast(address, messages, "auto");
Features
Graceful fallback to minGasPrice if feemarket query fails Min/max constraint enforcement with configurable multiplier backward compatible - existing code unchanged Automatic chain detection for Osmosis variants
Inspired by Hermes relayer PR #4004.
Thanks for the comments @webmaster128 will resolve remaining issues tomorrow, didnt have time this week yet.
changes made, ready for merge.
The commit cab1af03797ebbe5d9eaed6ea85d49cb4fc5b584 contains copies of a lot of dependencies. This is not needed and should not be done. Did you setup git-lfs? See also https://github.com/cosmos/cosmjs/blob/main/HACKING.md#checking-out-code. We need to ensure the code changes in here are separate from those things.
The last commit (the uncommitted dependency change) is not needed. See https://github.com/cosmos/cosmjs/issues/1922
The commit cab1af0 contains copies of a lot of dependencies. This is not needed and should not be done. Did you setup git-lfs? See also
main/HACKING.md#checking-out-code. We need to ensure the code changes in here are separate from those things.
The commits here are simply the result of a yarn install, if that is not correct then id suggest you do it however you want it but I don't see what there is to fix for me.
I have reset the yarn cache to main, with that state i cannot locally build this change.
Looks good overall, thank you. I will take care of linting and stuff to make CI happy tomorrow and then merge it
thanks for taking it over the line, hadnt worked with committing cache before and the issues it creates.