ault-sdk-ts 0.0.2-alpha.12 → 0.0.2-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eip712/sign-and-broadcast.d.ts +9 -1
- package/dist/index.cjs +93 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +89 -5
- package/dist/index.js.map +1 -1
- package/dist/rest/feemarket.d.ts +58 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type FetchFn, type FetchWithRetryOptions } from "../core/http";
|
|
2
|
+
import type { NetworkConfig } from "../core/network";
|
|
3
|
+
export interface FeeMarketParams {
|
|
4
|
+
noBaseFee: boolean;
|
|
5
|
+
/** Decimal string in aault per unit gas. */
|
|
6
|
+
baseFee: string;
|
|
7
|
+
/** Decimal string in aault per unit gas (chain-side floor). */
|
|
8
|
+
minGasPrice: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Fetch the current `cosmos/evm` feemarket params from the chain REST gateway.
|
|
12
|
+
*
|
|
13
|
+
* Throws on transport / 4xx / 5xx errors; callers wanting graceful fallback
|
|
14
|
+
* (e.g. for chains that don't expose the feemarket gateway) should use
|
|
15
|
+
* `getCachedFeeMarketParams` which absorbs the failure.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fetchFeeMarketParams(network: NetworkConfig, fetchFn?: FetchFn, fetchOptions?: FetchWithRetryOptions): Promise<FeeMarketParams>;
|
|
18
|
+
/**
|
|
19
|
+
* Compute the minimum fee amount (raw aault) required for the given gas
|
|
20
|
+
* limit under the supplied feemarket params, with a safety margin to absorb
|
|
21
|
+
* intra-block base-fee bumps. The chain's DynamicFeeChecker enforces
|
|
22
|
+
* `fee.amount / gas >= effective`, where `effective = max(baseFee, minGasPrice)`
|
|
23
|
+
* when base fee is enabled, else `minGasPrice` alone.
|
|
24
|
+
*
|
|
25
|
+
* Returns the smallest non-negative integer string `feeAmount` such that
|
|
26
|
+
* `feeAmount / gas >= effective * (1 + marginPercent/100)`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function computeRequiredFee(params: FeeMarketParams, gas: string | number | bigint, options?: {
|
|
29
|
+
marginPercent?: number;
|
|
30
|
+
}): string;
|
|
31
|
+
interface FeeMarketEntry {
|
|
32
|
+
params: FeeMarketParams | null;
|
|
33
|
+
fetchedAt: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Per-chain cache for feemarket params. Reused across tx submissions to
|
|
37
|
+
* avoid hitting `/params` on every signature; one entry per `chainId`.
|
|
38
|
+
*/
|
|
39
|
+
export interface FeeMarketCache {
|
|
40
|
+
ttlMs: number;
|
|
41
|
+
entries: Map<string, FeeMarketEntry>;
|
|
42
|
+
}
|
|
43
|
+
export declare function createFeeMarketCache(ttlMs?: number): FeeMarketCache;
|
|
44
|
+
/**
|
|
45
|
+
* Look up cached feemarket params or fetch fresh ones. Returns `null` only
|
|
46
|
+
* when the chain definitively does not expose the feemarket gateway — i.e.
|
|
47
|
+
* the gateway returns 404 (path not registered) or 501 (not implemented).
|
|
48
|
+
* Negative responses are cached for `ttlMs` to avoid re-spamming a chain
|
|
49
|
+
* that lacks the module.
|
|
50
|
+
*
|
|
51
|
+
* Transient failures (timeouts, network errors, 5xx) propagate unchanged so
|
|
52
|
+
* callers can decide whether to retry. Caching a transient miss would force
|
|
53
|
+
* every tx for `ttlMs` onto the static fallback fee, which on chains where
|
|
54
|
+
* `min_gas_price` exceeds the static default would underprice the tx and
|
|
55
|
+
* trigger the same "insufficient fee" rejection this module exists to avoid.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getCachedFeeMarketParams(cache: FeeMarketCache | undefined, network: NetworkConfig, fetchFn?: FetchFn, fetchOptions?: FetchWithRetryOptions): Promise<FeeMarketParams | null>;
|
|
58
|
+
export {};
|